Skip to content

Commit 9561605

Browse files
authored
Merge pull request #2162 from swiftwasm/main
[pull] swiftwasm from main
2 parents b20d154 + 5a87482 commit 9561605

File tree

68 files changed

+3813
-558
lines changed

Some content is hidden

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

68 files changed

+3813
-558
lines changed

include/swift/ABI/Task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class AsyncTask : public HeapObject, public Job {
182182
/// prevent it from being corrupted in flight.
183183
AsyncContext * __ptrauth_swift_task_resume_context ResumeContext;
184184

185-
/// The currntly-active information about cancellation.
185+
/// The currently-active information about cancellation.
186186
std::atomic<ActiveTaskStatus> Status;
187187

188188
/// Reserved for the use of the task-local stack allocator.

include/swift/ABI/TaskStatus.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ class DeadlineStatusRecord : public TaskStatusRecord {
124124
/// A status record which states that a task has one or
125125
/// more active child tasks.
126126
class ChildTaskStatusRecord : public TaskStatusRecord {
127-
/// FIXME: should this be an array? How are things like task
128-
/// nurseries supposed to actually manage this? Should it be
129-
/// atomically moodifiable?
127+
/// FIXME: should this be an array? How are things like task groups supposed
128+
/// to actually manage this? Should it be atomically modifiable?
130129
AsyncTask *FirstChild;
131130

132131
public:

include/swift/AST/AbstractSourceFileDepGraphFactory.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ class AbstractSourceFileDepGraphFactory {
6666
virtual void addAllUsedDecls() = 0;
6767

6868
protected:
69+
/// Given an array of Decls or pairs of them in \p declsOrPairs
70+
/// create node pairs for context and name
71+
template <NodeKind kind, typename ContentsT>
72+
void addAllDefinedDeclsOfAGivenType(std::vector<ContentsT> &contentsVec) {
73+
for (const auto &declOrPair : contentsVec) {
74+
Optional<std::string> fp =
75+
AbstractSourceFileDepGraphFactory::getFingerprintIfAny(declOrPair);
76+
addADefinedDecl(
77+
DependencyKey::createForProvidedEntityInterface<kind>(declOrPair),
78+
fp ? StringRef(fp.getValue()) : Optional<StringRef>());
79+
}
80+
}
81+
6982
/// Add an pair of interface, implementation nodes to the graph, which
7083
/// represent some \c Decl defined in this source file. \param key the
7184
/// interface key of the pair

include/swift/AST/Builtins.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,18 @@ BUILTIN_MISC_OPERATION(IntInstrprofIncrement, "int_instrprof_increment", "", Spe
717717
BUILTIN_MISC_OPERATION(Id, Name, Attrs, Overload)
718718
#endif
719719

720+
// getCurrentAsyncTask: () -> Builtin.NativeObject
721+
//
722+
// Retrieve the pointer to the task in which the current asynchronous
723+
// function is executing.
724+
BUILTIN_MISC_OPERATION_WITH_SILGEN(GetCurrentAsyncTask, "getCurrentAsyncTask", "n", Special)
725+
726+
/// cancelAsyncTask(): (Builtin.NativeObject) -> Void
727+
///
728+
/// Cancel the given asynchronous task.
729+
BUILTIN_MISC_OPERATION_WITH_SILGEN(CancelAsyncTask, "cancelAsyncTask", "", Special)
730+
731+
720732
/// globalStringTablePointer has type String -> Builtin.RawPointer.
721733
/// It returns an immortal, global string table pointer for strings constructed
722734
/// from string literals. We consider it effects as readnone meaning that it

include/swift/AST/Decl.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -5659,13 +5659,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56595659
/// Set a new body for the function.
56605660
void setBody(BraceStmt *S, BodyKind NewBodyKind);
56615661

5662-
/// Note that the body was skipped for this function. Function body
5662+
/// Note that the body was skipped for this function. Function body
56635663
/// cannot be attached after this call.
56645664
void setBodySkipped(SourceRange bodyRange) {
5665-
// FIXME: Remove 'Parsed' from this once we can delay parsing function
5666-
// bodies. Right now -experimental-skip-non-inlinable-function-bodies
5667-
// requires being able to change the state from Parsed to Skipped,
5668-
// because we're still eagerly parsing function bodies.
5665+
// FIXME: Remove 'Parsed' from this list once we can always delay
5666+
// parsing bodies. The -experimental-skip-*-function-bodies options
5667+
// do currently skip parsing, unless disabled through other means in
5668+
// SourceFile::hasDelayedBodyParsing (eg. needing to build the full
5669+
// syntax tree due to -verify-syntax-tree).
56695670
assert(getBodyKind() == BodyKind::None ||
56705671
getBodyKind() == BodyKind::Unparsed ||
56715672
getBodyKind() == BodyKind::Parsed);

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -128,8 +128,7 @@ ERROR(error_mode_cannot_emit_interface,none,
128128
ERROR(error_mode_cannot_emit_module_summary,none,
129129
"this mode does not support emitting module summary files", ())
130130
ERROR(cannot_emit_ir_skipping_function_bodies,none,
131-
"-experimental-skip-non-inlinable-function-bodies does not support "
132-
"emitting IR", ())
131+
"-experimental-skip-*-function-bodies do not support emitting IR", ())
133132

134133
WARNING(emit_reference_dependencies_without_primary_file,none,
135134
"ignoring -emit-reference-dependencies (requires -primary-file)", ())
@@ -416,7 +415,7 @@ ERROR(expectation_missing_opening_braces,none,
416415
ERROR(expectation_missing_closing_braces,none,
417416
"didn't find '}}' to match '{{' in expectation", ())
418417

419-
WARNING(module_incompatible_with_skip_function_bodies,none,
418+
WARNING(module_incompatible_with_skip_non_inlinable_function_bodies,none,
420419
"module '%0' cannot be built with "
421420
"-experimental-skip-non-inlinable-function-bodies; this option has "
422421
"been automatically disabled", (StringRef))

include/swift/AST/SILOptions.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -18,14 +18,15 @@
1818
#ifndef SWIFT_AST_SILOPTIONS_H
1919
#define SWIFT_AST_SILOPTIONS_H
2020

21-
#include "swift/Basic/Sanitizers.h"
22-
#include "swift/Basic/OptionSet.h"
21+
#include "swift/Basic/FunctionBodySkipping.h"
2322
#include "swift/Basic/OptimizationMode.h"
23+
#include "swift/Basic/OptionSet.h"
24+
#include "swift/Basic/Sanitizers.h"
2425
#include "llvm/ADT/Hashing.h"
2526
#include "llvm/ADT/StringRef.h"
2627
#include "llvm/Remarks/RemarkFormat.h"
27-
#include <string>
2828
#include <climits>
29+
#include <string>
2930

3031
namespace swift {
3132

@@ -88,8 +89,8 @@ class SILOptions {
8889
/// and go from OSSA to non-ownership SIL.
8990
bool StopOptimizationBeforeLoweringOwnership = false;
9091

91-
/// Whether to skip emitting non-inlinable function bodies.
92-
bool SkipNonInlinableFunctionBodies = false;
92+
// The kind of function bodies to skip emitting.
93+
FunctionBodySkipping SkipFunctionBodies = FunctionBodySkipping::None;
9394

9495
/// Optimization mode being used.
9596
OptimizationMode OptMode = OptimizationMode::NotSet;

include/swift/AST/Stmt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class BraceStmt final : public Stmt,
180180
ASTNode getLastElement() const { return getElements().back(); }
181181

182182
void setFirstElement(ASTNode node) { getElements().front() = node; }
183+
void setLastElement(ASTNode node) { getElements().back() = node; }
183184

184185
/// The elements contained within the BraceStmt.
185186
MutableArrayRef<ASTNode> getElements() {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===------------------- FunctionBodySkipping.h -----------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_BASIC_FUNCTIONBODYSKIPPING_H
14+
#define SWIFT_BASIC_FUNCTIONBODYSKIPPING_H
15+
16+
#include "llvm/Support/DataTypes.h"
17+
18+
namespace swift {
19+
20+
/// Describes the function bodies that can be skipped in type-checking.
21+
enum class FunctionBodySkipping : uint8_t {
22+
/// Do not skip type-checking for any function bodies.
23+
None,
24+
/// Only non-inlinable function bodies should be skipped.
25+
NonInlinable,
26+
/// All function bodies should be skipped, where not otherwise required
27+
/// for type inference.
28+
All
29+
};
30+
31+
} // end namespace swift
32+
33+
#endif // SWIFT_BASIC_FUNCTIONBODYSKIPPING_H

include/swift/Basic/LangOptions.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -18,18 +18,19 @@
1818
#ifndef SWIFT_BASIC_LANGOPTIONS_H
1919
#define SWIFT_BASIC_LANGOPTIONS_H
2020

21-
#include "swift/Config.h"
21+
#include "swift/Basic/FunctionBodySkipping.h"
2222
#include "swift/Basic/LLVM.h"
2323
#include "swift/Basic/Version.h"
24+
#include "swift/Config.h"
2425
#include "llvm/ADT/ArrayRef.h"
2526
#include "llvm/ADT/Hashing.h"
27+
#include "llvm/ADT/SmallString.h"
2628
#include "llvm/ADT/SmallVector.h"
2729
#include "llvm/ADT/StringRef.h"
28-
#include "llvm/ADT/SmallString.h"
2930
#include "llvm/ADT/Triple.h"
3031
#include "llvm/Support/Regex.h"
31-
#include "llvm/Support/raw_ostream.h"
3232
#include "llvm/Support/VersionTuple.h"
33+
#include "llvm/Support/raw_ostream.h"
3334
#include <string>
3435
#include <vector>
3536

@@ -489,9 +490,8 @@ namespace swift {
489490
/// dumped to llvm::errs().
490491
bool DebugTimeExpressions = false;
491492

492-
/// Indicate that the type checker should skip type-checking non-inlinable
493-
/// function bodies.
494-
bool SkipNonInlinableFunctionBodies = false;
493+
/// Controls the function bodies to skip during type-checking.
494+
FunctionBodySkipping SkipFunctionBodies = FunctionBodySkipping::None;
495495

496496
///
497497
/// Flags for developers

0 commit comments

Comments
 (0)