Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
58ad356
Refactored the `Stack.swift` file to make it more readable.
May 26, 2023
41f46ec
[Threading][TSan] Fix TSan errors from lazy init on Linux.
al45tair Jun 16, 2023
ee5efff
[Threading][TSan] Update after review comments.
al45tair Jun 19, 2023
8ed8a28
[Threading][TSan] Move ThreadSanitizer.cpp into the main runtime.
al45tair Jun 19, 2023
bad716f
[Threading][TSan] Rearrange things again.
al45tair Jun 19, 2023
3f0018d
[Threading][TSan] Fix linkage issue.
al45tair Jun 19, 2023
18b359f
[Threading][TSan] Fix builds where TSan isn't supported.
al45tair Jun 20, 2023
e1e933c
[ConstraintLocator] NFC: Add a way to check whether builder is pointi…
xedin Jun 21, 2023
5e30445
[CSSimplify] Add special handling if specialized type comes from `Typ…
xedin Jun 21, 2023
3b5ebaa
Fix some tests in IRGen folder
aschwaighofer May 31, 2023
599e82c
Fix more test/IRGen test cases
aschwaighofer Jun 2, 2023
a44b36c
Fix abitypes.swift, class_update_callback_without_fixed_layout.sil,dy…
aschwaighofer Jun 21, 2023
52961c9
Try to fix windows/linux
aschwaighofer Jun 21, 2023
059bbf5
[test][Backtracing] Fix crash message pattern for single threaded mode
kateinoigakukun Jun 21, 2023
4500aad
[DebugInfo][NFC] Update test to not check width of alloca integer arg…
felipepiovezan Jun 22, 2023
f38b9a9
[Threading][TSan] Update comments.
al45tair Jun 22, 2023
3f0c0f0
[Compile Time Constant Extraction] Add extraction of all conformances…
artemcm Jun 14, 2023
c5018f3
[Observation] Ensure lock storage rounding works for non-integral loc…
phausler Jun 22, 2023
e20be0e
Revert [Runtime] Let CF provide us with state, avoiding runtime looku…
Catfish-Man Jun 22, 2023
3202021
Merge pull request #66857 from Catfish-Man/revert-bridge-flip
gottesmm Jun 22, 2023
806fd1b
[Runtime] Handle generic single payload enums in resilient resolve (#…
drexin Jun 22, 2023
024efd2
SILGen: Don't emit key path property descriptors for properties in or…
jckarter Jun 22, 2023
4fc0be2
Merge pull request #66853 from felipepiovezan/felipe/alloca_size_int_…
felipepiovezan Jun 22, 2023
640a006
[DebugInfo][NFC] Update test to not check width of integer argument
felipepiovezan Jun 22, 2023
bbccbd3
Merge pull request #66179 from Mayank-84/Refactor/Stacks
swift-ci Jun 22, 2023
c3ae413
[Runtime] Use proper offset in generic multi payload enum layout stri…
drexin Jun 22, 2023
37220ed
[Runtime] Handle generic multi payload enums in resilient resolve (#6…
drexin Jun 22, 2023
4f4d014
Merge pull request #66721 from al45tair/eng/PR-110665213
al45tair Jun 22, 2023
b66dfad
[SourceKit] When AST-based cursor info is cancelled, don’t run solver…
ahoppen Jun 22, 2023
35661f2
[SourceKit] Inform consumers about cancellation from a background queue
ahoppen Jun 22, 2023
1980da9
Merge pull request #66812 from aschwaighofer/fix_some_opaque_ptr_test…
aschwaighofer Jun 22, 2023
957b465
Fix some IRGen tests on armv7k for opaque pointers
aschwaighofer Jun 22, 2023
5eee766
Fix test/IRGen/abitypes.swift
aschwaighofer Jun 22, 2023
49831a9
Fix @objcImpl crash with async/sync overloads
beccadax Jun 22, 2023
096d8ea
[CodeCompletion] Suggest synthesized declarations from macros
rintaro Jun 21, 2023
3e28a7c
[cxx-interop] Make libstdc++ header and modulemap arch-independent
egorzhdan Jun 22, 2023
037ddc9
[CursorInfo] Re-use already built ASTs ahead of currently building ones
bnbarham Jun 22, 2023
a92deb0
[GenericSignature] Exclude GenericParam Constraints
angela-laar Jun 21, 2023
9da65ca
Merge pull request #66865 from aschwaighofer/fix_opaque_pointer_irgen…
swift-ci Jun 22, 2023
a0fa946
[Completion] Add targetEnvironment(macCatalyst) platform condition
bnbarham Jun 22, 2023
31952cc
Merge pull request #66860 from jckarter/no-moveonly-property-descriptors
jckarter Jun 23, 2023
8d4a51b
Merge pull request #66858 from beccadax/names-out-of-sync
beccadax Jun 23, 2023
36ddb77
[IRGen+Runtime] Layout string getEnumTag for generic multi payload en…
drexin Jun 23, 2023
edc003a
Merge pull request #66850 from kateinoigakukun/katei/patch-series/rep…
kateinoigakukun Jun 23, 2023
536234b
Merge pull request #66859 from felipepiovezan/felipe/alloca_size_int_…
felipepiovezan Jun 23, 2023
12f01ce
Merge pull request #66855 from apple/egorzhdan/libstdcxx-arch-indepen…
egorzhdan Jun 23, 2023
dc60c07
[DebugInfo] Disable failing tests on watchOS
felipepiovezan Jun 23, 2023
511c344
[Build] Introduce --lldb-configure-tests option
Michael137 Jun 23, 2023
d72cc2c
Merge pull request #66879 from felipepiovezan/felipe/disable_watchos_…
swift-ci Jun 23, 2023
b91328c
Merge pull request #66866 from ahoppen/ahoppen/cursor-info-deadlock
ahoppen Jun 23, 2023
9a11e04
Merge pull request #66639 from artemcm/ConstExtractConformanceInfo
artemcm Jun 23, 2023
1d7c534
Merge pull request #66839 from bnbarham/reuse-cursor-ast
bnbarham Jun 23, 2023
3ea3234
Merge pull request #66875 from bnbarham/add-maccatalyst-completion
bnbarham Jun 23, 2023
ce4ec06
Merge pull request #66796 from xedin/rdar-111059036
xedin Jun 23, 2023
196ea79
Merge pull request #66821 from rintaro/completion-macro-expanded-rdar…
rintaro Jun 23, 2023
6607f05
Merge pull request #66864 from angela-laar/exclude-generic-param-cons…
angela-laar Jun 23, 2023
e9ff334
Fix missing indexing data with overloaded type (#65729)
keith Jun 23, 2023
821e260
Merge pull request #66880 from Michael137/bugfix/build-script-configu…
JDevlieghere Jun 23, 2023
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
20 changes: 10 additions & 10 deletions SwiftCompilerSources/Sources/Optimizer/DataStructures/Stack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ struct Stack<Element> : CollectionLikeSequence {

mutating func next() -> Element? {
let end = (slab.data == lastSlab.data ? endIndex : slabCapacity)
if index < end {
let elem = Stack.bind(slab)[index]
index += 1

if index >= end && slab.data != lastSlab.data {
slab = slab.getNext()
index = 0
}
return elem

guard index < end else { return nil }

let elem = Stack.bind(slab)[index]
index += 1

if index >= end && slab.data != lastSlab.data {
slab = slab.getNext()
index = 0
}
return nil
return elem
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmake/modules/AddSwiftUnittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function(add_swift_unittest test_dirname)

string(TOUPPER "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_THREADING_PACKAGE}" _threading_package)
target_compile_definitions("${test_dirname}" PRIVATE
"SWIFT_THREADING_${_threading_package}")
"SWIFT_THREADING_${_threading_package}"
"SWIFT_THREADING_STATIC")

if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
if(SWIFT_USE_LINKER)
Expand Down
28 changes: 28 additions & 0 deletions include/swift/AST/TypeRepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,33 @@ class FixedTypeRepr : public TypeRepr {
friend class TypeRepr;
};

/// A TypeRepr for uses of 'Self' in the type of a declaration.
class SelfTypeRepr : public TypeRepr {
Type Ty;
SourceLoc Loc;

public:
SelfTypeRepr(Type Ty, SourceLoc Loc)
: TypeRepr(TypeReprKind::Self), Ty(Ty), Loc(Loc) {}

/// Retrieve the location.
SourceLoc getLoc() const { return Loc; }

/// Retrieve the fixed type.
Type getType() const { return Ty; }

static bool classof(const TypeRepr *T) {
return T->getKind() == TypeReprKind::Self;
}
static bool classof(const SelfTypeRepr *T) { return true; }

private:
SourceLoc getStartLocImpl() const { return Loc; }
SourceLoc getEndLocImpl() const { return Loc; }
void printImpl(ASTPrinter &Printer, const PrintOptions &Opts) const;
friend class TypeRepr;
};

class SILBoxTypeReprField {
SourceLoc VarOrLetLoc;
llvm::PointerIntPair<TypeRepr*, 1, bool> FieldTypeAndMutable;
Expand Down Expand Up @@ -1436,6 +1463,7 @@ inline bool TypeRepr::isSimple() const {
case TypeReprKind::Pack:
case TypeReprKind::Tuple:
case TypeReprKind::Fixed:
case TypeReprKind::Self:
case TypeReprKind::Array:
case TypeReprKind::SILBox:
case TypeReprKind::Isolated:
Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/TypeReprNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ ABSTRACT_TYPEREPR(Specifier, TypeRepr)
SPECIFIER_TYPEREPR(CompileTimeConst, SpecifierTypeRepr)
TYPEREPR(Fixed, TypeRepr)
TYPEREPR(SILBox, TypeRepr)
LAST_TYPEREPR(SILBox)
TYPEREPR(Self, TypeRepr)
LAST_TYPEREPR(Self)

#undef SPECIFIER_TYPEREPR
#undef ABSTRACT_TYPEREPR
Expand Down
10 changes: 10 additions & 0 deletions include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,16 @@ FUNCTION(GenericInitWithTake,
ATTRS(NoUnwind),
EFFECT(Refcounting))

// unsigned swift_multiPayloadEnumGeneric_getEnumTag(opaque* address,
// const Metadata *type);
FUNCTION(MultiPayloadEnumGenericGetEnumTag,
swift_multiPayloadEnumGeneric_getEnumTag,
C_CC, AlwaysAvailable,
RETURNS(Int32Ty),
ARGS(Int8PtrTy, TypeMetadataPtrTy),
ATTRS(NoUnwind),
EFFECT(NoEffect))

// void swift_generic_instantiateLayoutString(const uint8_t* layoutStr, Metadata* type);
FUNCTION(GenericInstantiateLayoutString,
swift_generic_instantiateLayoutString,
Expand Down
9 changes: 9 additions & 0 deletions include/swift/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,15 @@ class ConstraintLocatorBuilder {
return ConstraintLocatorBuilder(this, newElt, newFlags);
}

/// Determine whether this locator builder points directly to a
/// given expression.
template <typename E>
bool directlyAt() const {
if (auto *expr = getAnchor().dyn_cast<Expr *>())
return isa<E>(expr) && hasEmptyPath();
return false;
}

/// Determine whether this builder has an empty path.
bool hasEmptyPath() const {
return !element;
Expand Down
29 changes: 19 additions & 10 deletions include/swift/Threading/Impl/Linux/ulock.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <atomic>
#include <cstdint>

#include "swift/Threading/ThreadSanitizer.h"

namespace swift {
namespace threading_impl {
namespace linux {
Expand All @@ -59,31 +61,38 @@ inline void ulock_lock(ulock_t *lock) {
const ulock_t tid = ulock_get_tid();
do {
ulock_t zero = 0;
if (ulock_fastpath(__atomic_compare_exchange_n(
lock, &zero, tid, true, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)))
return;

if (ulock_fastpath(__atomic_compare_exchange_n(lock, &zero, tid,
true, __ATOMIC_ACQUIRE,
__ATOMIC_RELAXED)))
break;
} while (ulock_futex(lock, FUTEX_LOCK_PI) != 0);

tsan::acquire(lock);
}

inline bool ulock_trylock(ulock_t *lock) {
ulock_t zero = 0;
if (ulock_fastpath(__atomic_compare_exchange_n(lock, &zero, ulock_get_tid(),
true, __ATOMIC_ACQUIRE,
__ATOMIC_RELAXED)))
__ATOMIC_RELAXED))
|| ulock_futex(lock, FUTEX_TRYLOCK_PI) == 0) {
tsan::acquire(lock);
return true;
}

return ulock_futex(lock, FUTEX_TRYLOCK_PI) == 0;
return false;
}

inline void ulock_unlock(ulock_t *lock) {
tsan::release(lock);

const ulock_t tid = ulock_get_tid();
do {
ulock_t expected = tid;
if (ulock_fastpath(__atomic_compare_exchange_n(
lock, &expected, 0, true, __ATOMIC_RELEASE, __ATOMIC_RELAXED)))
return;

if (ulock_fastpath(__atomic_compare_exchange_n(lock, &expected, 0,
true, __ATOMIC_RELEASE,
__ATOMIC_RELAXED)))
break;
} while (ulock_futex(lock, FUTEX_UNLOCK_PI) != 0);
}

Expand Down
120 changes: 120 additions & 0 deletions include/swift/Threading/ThreadSanitizer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//===--- ThreadSanitizer.h - Thread Sanitizer support --------- -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2023 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
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Helper functions for code that needs to integrate with the thread
// sanitizer. In particular, TSan can't see inside the runtime libraries,
// so we occasionally need to give it a hint that we're doing synchronization
// in order to avoid false positives.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_THREADING_THREAD_SANITIZER_H
#define SWIFT_THREADING_THREAD_SANITIZER_H

#include "swift/shims/Visibility.h"

namespace swift {

#if defined(_WIN32) || defined(__wasi__) || !__has_include(<dlfcn.h>)

#define SWIFT_THREADING_TSAN_SUPPORT 0

namespace tsan {

inline bool enabled() { return false; }
template <typename T> T *acquire(T *ptr) { return ptr; }
template <typename T> T *release(T *ptr) { return ptr; }

} // namespace tsan
#else

#define SWIFT_THREADING_TSAN_SUPPORT 1

// If we're static linking to libswiftThreading.a, these symbols can come
// from there. If, on the other hand, we're dynamically linked, we want
// to get them from libswiftCore.dylib instead.
#if SWIFT_THREADING_STATIC
#define SWIFT_THREADING_EXPORT extern "C"
#else
#define SWIFT_THREADING_EXPORT SWIFT_RUNTIME_EXPORT
#endif

namespace threading_impl {

SWIFT_THREADING_EXPORT bool _swift_tsan_enabled;
SWIFT_THREADING_EXPORT void (*_swift_tsan_acquire)(const void *ptr);
SWIFT_THREADING_EXPORT void (*_swift_tsan_release)(const void *ptr);

} // namespace threading_impl

namespace tsan {

/// Returns true if TSan is enabled
inline bool enabled() {
return threading_impl::_swift_tsan_enabled;
}

/// Inform TSan about a synchronization operation.
///
/// This is used when TSan cannot see the synchronization operation, for
/// example, if it is using a custom primitive for which TSan doesn't have
/// a built-in interceptor. This does not necessarily mean a lock or a C(++)
/// atomic operation - it could be any kind of synchronization mechanism.
///
/// An acquire-release pair using the same address establishes an ordering
/// constraint in TSan's happens-before graph, which TSan uses to determine
/// whether two memory accesses from different threads have a well-defined
/// order.
///
/// For instance, in
///
/// Thread 1 Thread 2
///
/// access to y
/// tsan::release(x)
/// lock given away
///
/// --> sync point -->
///
/// lock taken
/// tsan::acquire(x)
/// access to y
///
/// the access to y from Thread 2 is safe relative to the preceding access to
/// y on Thread 1 because it is preceded by an acquire of x that was itself
/// preceded by a release of x.
template <typename T>
T *acquire(T *ptr) {
if (threading_impl::_swift_tsan_acquire) {
threading_impl::_swift_tsan_acquire(ptr);
}
return ptr;
}

/// Inform TSan about a synchronization operation.
///
/// This is the counterpart to tsan::acquire.
template <typename T>
T *release(T *ptr) {
if (threading_impl::_swift_tsan_release) {
threading_impl::_swift_tsan_release(ptr);
}
return ptr;
}

} // namespace tsan

#endif

} // namespace swift

#endif
16 changes: 16 additions & 0 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3352,6 +3352,22 @@ class PrintTypeRepr : public TypeReprVisitor<PrintTypeRepr> {
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}

void visitSelfTypeRepr(SelfTypeRepr *T) {
printCommon("type_self");
auto Ty = T->getType();
if (Ty) {
auto &srcMgr = Ty->getASTContext().SourceMgr;
if (T->getLoc().isValid()) {
OS << " location=@";
T->getLoc().print(OS, srcMgr);
} else {
OS << " location=<<invalid>>";
}
}
OS << " type="; Ty.dump(OS);
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}

void visitSILBoxTypeRepr(SILBoxTypeRepr *T) {
printCommon("sil_box");
Indent += 2;
Expand Down
4 changes: 4 additions & 0 deletions lib/AST/ASTWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,10 @@ bool Traversal::visitFixedTypeRepr(FixedTypeRepr *T) {
return false;
}

bool Traversal::visitSelfTypeRepr(SelfTypeRepr *T) {
return false;
}

bool Traversal::visitSILBoxTypeRepr(SILBoxTypeRepr *T) {
for (auto &field : T->getFields()) {
if (doIt(field.getFieldType()))
Expand Down
4 changes: 4 additions & 0 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,10 @@ bool ValueDecl::shouldHideFromEditor() const {
getBaseIdentifier().str().startswith("$__"))
return true;

// Macro unique names are only intended to be used inside the expanded code.
if (MacroDecl::isUniqueMacroName(getBaseName()))
return true;

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/GenericSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ Type GenericSignatureImpl::getUpperBound(Type type,
abort();
}

if (!hasInnerGenericParam)
if (!hasInnerGenericParam && (wantDependentBound || !hasOuterGenericParam))
argTypes.push_back(reducedType);
}

Expand Down
Loading