Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2f6f051
Use rsync for remote-run.
al45tair Feb 1, 2022
458eccc
[LibSwiftScan] Add entry-points for querying protocol conformances fr…
artemcm Feb 1, 2022
4f28b87
basic implementation of flow-isolation for SE-327
kavon Nov 3, 2021
8432f94
(rdar://87412308) fix missing actor hop for global-actor isolated ini…
kavon Jan 11, 2022
d610493
fix bugs with actor inits and flow-isolation
kavon Jan 11, 2022
3e60e12
update observers test to require concurrency
kavon Jan 13, 2022
94553fd
allow nonisolated + async + delegating actor inits.
kavon Jan 13, 2022
f3c6519
cleanup
kavon Jan 27, 2022
67d7f95
test updates after rebasing on main
kavon Jan 31, 2022
df577f2
Fix SR-15785 by adding a cached reference to the last linked list nod…
Catfish-Man Feb 2, 2022
1707ffe
Review feedback
Catfish-Man Feb 3, 2022
25ab410
Implement (Sugared) Bound Generic Extensions
CodaFi Feb 3, 2022
1186b1c
Merge pull request #40028 from kavon/flowsensitive-isolation
swift-ci Feb 3, 2022
6c23d92
Merge pull request #41125 from al45tair/eng/PR-88179140.rsync
al45tair Feb 3, 2022
ee7e048
Add a -reflection-metadata-for-debugger-only flag that emits reflecti…
kubamracek Feb 3, 2022
3336e2d
Merge pull request #41106 from artemcm/StaticMirrorScannerLib
artemcm Feb 3, 2022
f5b4092
Merge pull request #41172 from CodaFi/special-sauce
CodaFi Feb 3, 2022
973f5d2
[Concurrency] Disable flaky test (#40875)
philipturner Feb 3, 2022
4b8ba3c
Don't Unnecessarily Invalidate Unreferenced Generic Parameters (#41128)
philipturner Feb 3, 2022
039403c
Merge pull request #41165 from Catfish-Man/linked-lost
Catfish-Man Feb 3, 2022
2b2dd23
Fix missing argument in utils/swift-api-dump.py. (#41178)
rxwei Feb 3, 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
77 changes: 77 additions & 0 deletions include/swift-c/DependencyScan/BinaryScan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//===--- BinaryScan.h - C API for Swift Binary Scanning ---*- C -*-===//
//
// This source file is part of the Swift.org open source project
//
// 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
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This C API is primarily intended to serve as a "static mirror" library
// for querying Swift type information from binary object files.
//
//===----------------------------------------------------------------------===//

#include "DependencyScanMacros.h"
#include "CommonString.h"

#ifndef SWIFT_C_BINARY_SCAN_H
#define SWIFT_C_BINARY_SCAN_H

SWIFTSCAN_BEGIN_DECLS

//=== Public Binary Scanner Data Types ------------------------------------===//

/// Container of the configuration state for binary static mirror scanning
/// instance
typedef void *swiftscan_static_mirror_t;

/// Opaque container to a conformance type info of a given protocol conformance.
typedef struct swiftscan_conformance_info_s
*swiftscan_static_mirror_conformance_info_t;

typedef struct {
swiftscan_static_mirror_conformance_info_t *conformances;
size_t count;
} swiftscan_static_mirror_conformances_set_t;

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_static_mirror_conformance_info_get_type_name(
swiftscan_static_mirror_conformance_info_t);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_static_mirror_conformance_info_get_protocol_name(
swiftscan_static_mirror_conformance_info_t);

SWIFTSCAN_PUBLIC swiftscan_string_ref_t
swiftscan_static_mirror_conformance_info_get_mangled_type_name(
swiftscan_static_mirror_conformance_info_t);

SWIFTSCAN_PUBLIC void
swiftscan_static_mirror_conformance_info_dispose(
swiftscan_static_mirror_conformance_info_t);

/// Create an \c swiftscan_static_mirror_t instance.
/// The returned \c swiftscan_static_mirror_t is owned by the caller and must be
/// disposed of using \c swiftscan_static_mirror_dispose .
SWIFTSCAN_PUBLIC swiftscan_static_mirror_t
swiftscan_static_mirror_create(int, const char **, const char *);

SWIFTSCAN_PUBLIC void
swiftscan_static_mirror_dispose(swiftscan_static_mirror_t);

/// Identify and collect all types conforming to any of the protocol names
/// specified as arguments
SWIFTSCAN_PUBLIC swiftscan_static_mirror_conformances_set_t *
swiftscan_static_mirror_conformances_set_create(
swiftscan_static_mirror_t, int, const char **);

SWIFTSCAN_PUBLIC void swiftscan_static_mirror_conformances_set_dispose(
swiftscan_static_mirror_conformances_set_t *);

SWIFTSCAN_END_DECLS

#endif // SWIFT_C_BINARY_SCAN_H
41 changes: 41 additions & 0 deletions include/swift-c/DependencyScan/CommonString.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===--- CommonString.h - C API for Swift Dependency Scanning ---*- C -*-===//
//
// This source file is part of the Swift.org open source project
//
// 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
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_C_LIB_SWIFT_SCAN_STRING_H
#define SWIFT_C_LIB_SWIFT_SCAN_STRING_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

SWIFTSCAN_BEGIN_DECLS

//=== String Data Types used by LibSwift Scan ----------------------------===//

/**
* A character string used to pass around dependency scan result metadata.
* Lifetime of the string is strictly tied to the object whose field it
* represents. When the owning object is released, string memory is freed.
*/
typedef struct {
const void *data;
size_t length;
} swiftscan_string_ref_t;

typedef struct {
swiftscan_string_ref_t *strings;
size_t count;
} swiftscan_string_set_t;

SWIFTSCAN_END_DECLS

#endif // SWIFT_C_DEPENDENCY_SCAN_H
33 changes: 6 additions & 27 deletions include/swift-c/DependencyScan/DependencyScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,15 @@
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_C_DEPENDENCY_SCAN_H
#define SWIFT_C_DEPENDENCY_SCAN_H

#include "DependencyScanMacros.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "CommonString.h"

/// The version constants for the SwiftDependencyScan C API.
/// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
/// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
#define SWIFTSCAN_VERSION_MAJOR 0
#define SWIFTSCAN_VERSION_MINOR 2
#ifndef SWIFT_C_DEPENDENCY_SCAN_H
#define SWIFT_C_DEPENDENCY_SCAN_H

SWIFTSCAN_BEGIN_DECLS

//=== Public Scanner Data Types -------------------------------------------===//

/**
* A character string used to pass around dependency scan result metadata.
* Lifetime of the string is strictly tied to the object whose field it
* represents. When the owning object is released, string memory is freed.
*/
typedef struct {
const void *data;
size_t length;
} swiftscan_string_ref_t;

typedef struct {
swiftscan_string_ref_t *strings;
size_t count;
} swiftscan_string_set_t;
//=== Public Dependency Scanner Data Types -------------------------------===//

typedef enum {
// This dependency info encodes two ModuleDependencyKind types:
Expand Down Expand Up @@ -368,6 +345,8 @@ swiftscan_scanner_cache_load(swiftscan_scanner_t scanner,
SWIFTSCAN_PUBLIC void
swiftscan_scanner_cache_reset(swiftscan_scanner_t scanner);

//=== Experimental compiler invocation operations -------------------------===//

/// An entry point to invoke the compiler via a library call.
SWIFTSCAN_PUBLIC int invoke_swift_compiler(int argc, const char **argv);

Expand Down
32 changes: 32 additions & 0 deletions include/swift-c/DependencyScan/LibSwiftScan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===--- LibSwiftScan.h - C API for Swift Dependency Scanning ---*- C ---*-===//
//
// This source file is part of the Swift.org open source project
//
// 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
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This C API is primarily intended to serve as:
// - Swift Driver's dependency scanning facility
// (https://github.com/apple/swift-driver).
// - An object-file scanning facility for extracting of Swift type information
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_C_SWIFT_SCAN_H
#define SWIFT_C_SWIFT_SCAN_H

/// The version constants for the SwiftDependencyScan C API.
/// SWIFTSCAN_VERSION_MINOR should increase when there are API additions.
/// SWIFTSCAN_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
#define SWIFTSCAN_VERSION_MAJOR 0
#define SWIFTSCAN_VERSION_MINOR 3

#include "DependencyScan.h"
#include "BinaryScan.h"

#endif // SWIFT_C_SWIFT_SCAN_H
2 changes: 1 addition & 1 deletion include/swift-c/DependencyScan/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module _InternalSwiftScan {
header "DependencyScan.h"
header "LibSwiftScan.h"
link "_InternalSwiftScan"
}
40 changes: 20 additions & 20 deletions include/swift/ABI/TaskStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,21 @@ class ChildTaskStatusRecord : public TaskStatusRecord {
/// and are only tracked by their respective `TaskGroupTaskStatusRecord`.
class TaskGroupTaskStatusRecord : public TaskStatusRecord {
AsyncTask *FirstChild;
AsyncTask *LastChild;

public:
TaskGroupTaskStatusRecord()
: TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild(nullptr) {
: TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
FirstChild(nullptr),
LastChild(nullptr) {
}

TaskGroupTaskStatusRecord(AsyncTask *child)
: TaskStatusRecord(TaskStatusRecordKind::TaskGroup), FirstChild(child) {}
: TaskStatusRecord(TaskStatusRecordKind::TaskGroup),
FirstChild(child),
LastChild(child) {
assert(!LastChild || !LastChild->childFragment()->getNextChild());
}

TaskGroup *getGroup() { return reinterpret_cast<TaskGroup *>(this); }

Expand All @@ -185,38 +192,28 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
assert(child->hasGroupChildFragment());
assert(child->groupChildFragment()->getGroup() == getGroup());

auto oldLastChild = LastChild;
LastChild = child;

if (!FirstChild) {
// This is the first child we ever attach, so store it as FirstChild.
FirstChild = child;
return;
}

// We need to traverse the siblings to find the last one and add the child
// there.
// FIXME: just set prepend to the current head, no need to traverse.

auto cur = FirstChild;
while (cur) {
// no need to check hasChildFragment, all tasks we store here have them.
auto fragment = cur->childFragment();
if (auto next = fragment->getNextChild()) {
cur = next;
} else {
// we're done searching and `cur` is the last
break;
}
}

cur->childFragment()->setNextChild(child);
oldLastChild->childFragment()->setNextChild(child);
}

void detachChild(AsyncTask *child) {
assert(child && "cannot remove a null child from group");
if (FirstChild == child) {
FirstChild = getNextChildTask(child);
if (FirstChild == nullptr) {
LastChild = nullptr;
}
return;
}

AsyncTask *prev = FirstChild;
// Remove the child from the linked list, i.e.:
// prev -> afterPrev -> afterChild
Expand All @@ -230,6 +227,9 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
if (afterPrev == child) {
auto afterChild = getNextChildTask(child);
prev->childFragment()->setNextChild(afterChild);
if (child == LastChild) {
LastChild = prev;
}
return;
}

Expand Down
10 changes: 10 additions & 0 deletions include/swift/AST/ActorIsolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class raw_ostream;
namespace swift {
class DeclContext;
class ModuleDecl;
class VarDecl;
class NominalTypeDecl;
class SubstitutionMap;
class AbstractFunctionDecl;

/// Determine whether the given types are (canonically) equal, declared here
/// to avoid having to include Types.h.
Expand All @@ -36,6 +38,11 @@ bool areTypesEqual(Type type1, Type type2);
/// Determine whether the given type is suitable as a concurrent value type.
bool isSendableType(ModuleDecl *module, Type type);

/// Determines if the 'let' can be read from anywhere within the given module,
/// regardless of the isolation or async-ness of the context in which
/// the var is read.
bool isLetAccessibleAnywhere(const ModuleDecl *fromModule, VarDecl *let);

/// Describes the actor isolation of a given declaration, which determines
/// the actors with which it can interact.
class ActorIsolation {
Expand Down Expand Up @@ -169,6 +176,9 @@ ActorIsolation getActorIsolation(ValueDecl *value);
/// Determine how the given declaration context is isolated.
ActorIsolation getActorIsolationOfContext(DeclContext *dc);

/// Determines whether this function's body uses flow-sensitive isolation.
bool usesFlowSensitiveIsolation(AbstractFunctionDecl const *fn);

void simple_display(llvm::raw_ostream &out, const ActorIsolation &state);

} // end namespace swift
Expand Down
23 changes: 10 additions & 13 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,6 @@ ERROR(variable_defer_use_uninit,none,
ERROR(self_closure_use_uninit,none,
"'self' captured by a closure before all members were initialized", ())

ERROR(self_disallowed_nonisolated_actor_init,none,
"%select{|this use of }0actor 'self' cannot %2 %select{from|in}0 "
"%select{a non-isolated, designated|a global-actor isolated}1 initializer",
(bool, bool, StringRef))
ERROR(self_disallowed_plain_actor_init,none,
"%select{|this use of }0actor 'self' can only %1 %select{from|in}0 an async initializer",
(bool, StringRef))
NOTE(actor_convenience_init,none,
"convenience initializers allow non-isolated use of 'self' once "
"initialized",
())




ERROR(variable_addrtaken_before_initialized,none,
Expand Down Expand Up @@ -625,6 +612,16 @@ WARNING(warning_int_to_fp_inexact, none,
"'%1' is not exactly representable as %0; it becomes '%2'",
(Type, StringRef, StringRef))

// Flow-isolation diagnostics
ERROR(isolated_after_nonisolated, none,
"cannot access %1 %2 here in %select{non-isolated initializer|deinitializer}0",
(bool, DescriptiveDeclKind, DeclName))
NOTE(nonisolated_blame, none, "after %1%2 %3, "
"only non-isolated properties of 'self' can be accessed from "
"%select{this init|a deinit}0", (bool, StringRef, StringRef, DeclName))
ERROR(non_sendable_from_deinit,none,
"cannot access %1 %2 with a non-sendable type %0 from non-isolated deinit",
(Type, DescriptiveDeclKind, DeclName))

// Yield usage errors
ERROR(return_before_yield, none, "accessor must yield before returning",())
Expand Down
5 changes: 2 additions & 3 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,8 @@ ERROR(extension_metatype,none,
ERROR(extension_specialization,none,
"constrained extension must be declared on the unspecialized generic "
"type %0 with constraints specified by a 'where' clause", (Identifier))
ERROR(extension_placeholder,none,
"cannot extend a type that contains placeholders", ())
ERROR(extension_stored_property,none,
"extensions must not contain stored properties", ())
NOTE(extension_stored_property_fixit,none,
Expand Down Expand Up @@ -4708,9 +4710,6 @@ ERROR(nonisolated_local_var,none,
ERROR(nonisolated_actor_sync_init,none,
"'nonisolated' on an actor's synchronous initializer is invalid",
())
ERROR(nonisolated_actor_convenience_init,none,
"'nonisolated' on an actor's convenience initializer is redundant",
())

ERROR(actor_instance_property_wrapper,none,
"%0 property in property wrapper type %1 cannot be isolated to "
Expand Down
Loading