Skip to content

[pull] swiftwasm from main #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ae9715a
WinSDK: extract System submodule with winioctl.h
egorzhdan Oct 1, 2020
04c21c1
Parse: Disable circular definition check when parser lookup is off
slavapestov Sep 22, 2020
4648587
ASTScope: Move sortBySourceRange() and cull() calls out of addSibling…
slavapestov Oct 1, 2020
8b2cf55
ASTScope: Push isLocalBinding down from AbstractPatternEntryScope to …
slavapestov Oct 2, 2020
4f1ab9d
ASTScope: Directly calculate end location of GuardStmtScope and Patte…
slavapestov Oct 2, 2020
e100449
[NFC] Split ProtocolDispatchStrategy out of MetadataValues.h.
rjmccall Oct 3, 2020
66a42d8
[NFC] Move some of the runtime's compiler abstraction into Compiler.h
rjmccall Oct 3, 2020
0fb4079
[NFC] Rename swift_runtime_unreachable to swift_unreachable and make …
rjmccall Oct 3, 2020
ffe21d4
Sema: Diagnose duplicate capture list entires when parser lookup is off
slavapestov Oct 2, 2020
854e1e4
Frontend: Add -enable-parser-lookup flag
slavapestov Sep 23, 2020
bd36100
Update tests in preparation for disabling parser lookup
slavapestov Oct 2, 2020
24c80a3
Merge pull request #34158 from slavapestov/prepare-to-disable-parser-…
slavapestov Oct 3, 2020
6a43108
Merge pull request #34147 from egorzhdan/winsdk-ioctl
egorzhdan Oct 3, 2020
9294c07
CI: add concurrency to the Windows CI set
compnerd Oct 3, 2020
d1070da
Merge pull request #34172 from rjmccall/compiler-abstraction
rjmccall Oct 3, 2020
573886d
[build] Remove forced tracing of lldb dotest
kastiglione Oct 2, 2020
677fcbf
Merge pull request #34173 from compnerd/concurrency
compnerd Oct 3, 2020
f190342
Merge pull request #34167 from apple/dl/build-Remove-forced-tracing-o…
kastiglione Oct 3, 2020
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
6 changes: 6 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,9 @@ macro(add_swift_tool_symlink name dest component)
add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE COMPONENT ${component})
endmacro()

# Declare that files in this library are built with LLVM's support
# libraries available.
macro(set_swift_llvm_is_available)
add_compile_options(-DSWIFT_LLVM_SUPPORT_IS_AVAILABLE)
endmacro()
14 changes: 7 additions & 7 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "swift/Basic/RelativePointer.h"
#include "swift/Demangling/Demangle.h"
#include "swift/Demangling/ManglingMacros.h"
#include "swift/Runtime/Unreachable.h"
#include "swift/Basic/Unreachable.h"
#include "../../../stdlib/public/SwiftShims/HeapObject.h"
#if SWIFT_OBJC_INTEROP
#include <objc/runtime.h>
Expand Down Expand Up @@ -4664,7 +4664,7 @@ int32_t TargetTypeContextDescriptor<Runtime>::getGenericArgumentOffset() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getGenericArgumentOffset();
default:
swift_runtime_unreachable("Not a type context descriptor.");
swift_unreachable("Not a type context descriptor.");
}
}

Expand All @@ -4682,7 +4682,7 @@ TargetTypeContextDescriptor<Runtime>::getFullGenericContextHeader() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getFullGenericContextHeader();
default:
swift_runtime_unreachable("Not a type context descriptor.");
swift_unreachable("Not a type context descriptor.");
}
}

Expand All @@ -4699,7 +4699,7 @@ TargetTypeContextDescriptor<Runtime>::getGenericParams() const {
case ContextDescriptorKind::OpaqueType:
return llvm::cast<TargetOpaqueTypeDescriptor<Runtime>>(this)->getGenericParams();
default:
swift_runtime_unreachable("Not a type context descriptor.");
swift_unreachable("Not a type context descriptor.");
}
}

Expand All @@ -4717,7 +4717,7 @@ TargetTypeContextDescriptor<Runtime>::getForeignMetadataInitialization() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getForeignMetadataInitialization();
default:
swift_runtime_unreachable("Not a type context descriptor.");
swift_unreachable("Not a type context descriptor.");
}
}

Expand All @@ -4735,7 +4735,7 @@ TargetTypeContextDescriptor<Runtime>::getSingletonMetadataInitialization() const
return llvm::cast<TargetClassDescriptor<Runtime>>(this)
->getSingletonMetadataInitialization();
default:
swift_runtime_unreachable("Not a enum, struct or class type descriptor.");
swift_unreachable("Not a enum, struct or class type descriptor.");
}
}

Expand All @@ -4753,7 +4753,7 @@ TargetTypeContextDescriptor<Runtime>::getCanonicicalMetadataPrespecializations()
return llvm::cast<TargetClassDescriptor<Runtime>>(this)
->getCanonicicalMetadataPrespecializations();
default:
swift_runtime_unreachable("Not a type context descriptor.");
swift_unreachable("Not a type context descriptor.");
}
}

Expand Down
29 changes: 2 additions & 27 deletions include/swift/ABI/MetadataValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#define SWIFT_ABI_METADATAVALUES_H

#include "swift/ABI/KeyPath.h"
#include "swift/ABI/ProtocolDispatchStrategy.h"
#include "swift/AST/Ownership.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/FlagSet.h"
#include "swift/Runtime/Unreachable.h"

#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -410,20 +410,6 @@ enum class SpecialProtocol: uint8_t {
Error = 1,
};

/// Identifiers for protocol method dispatch strategies.
enum class ProtocolDispatchStrategy: uint8_t {
/// Uses ObjC method dispatch.
///
/// This must be 0 for ABI compatibility with Objective-C protocol_t records.
ObjC = 0,

/// Uses Swift protocol witness table dispatch.
///
/// To invoke methods of this protocol, a pointer to a protocol witness table
/// corresponding to the protocol conformance must be available.
Swift = 1,
};

/// Flags for protocol descriptors.
class ProtocolDescriptorFlags {
typedef uint32_t int_type;
Expand Down Expand Up @@ -486,18 +472,7 @@ class ProtocolDescriptorFlags {

/// Does the protocol require a witness table for method dispatch?
bool needsWitnessTable() const {
return needsWitnessTable(getDispatchStrategy());
}

static bool needsWitnessTable(ProtocolDispatchStrategy strategy) {
switch (strategy) {
case ProtocolDispatchStrategy::ObjC:
return false;
case ProtocolDispatchStrategy::Swift:
return true;
}

swift_runtime_unreachable("Unhandled ProtocolDispatchStrategy in switch.");
return swift::protocolRequiresWitnessTable(getDispatchStrategy());
}

/// Return the identifier if this is a special runtime-known protocol.
Expand Down
54 changes: 54 additions & 0 deletions include/swift/ABI/ProtocolDispatchStrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//===--- ProtocolDispatchStrategy.h - ---------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 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 header declares the ProtocolDispatchStrategy enum and some
// related operations. It's split out because we would otherwise need
// to include MetadataValues.h in some relatively central headers.s
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H
#define SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H

#include "swift/Basic/Unreachable.h"

namespace swift {

/// Identifiers for protocol method dispatch strategies.
enum class ProtocolDispatchStrategy: uint8_t {
/// Uses ObjC method dispatch.
///
/// This must be 0 for ABI compatibility with Objective-C protocol_t records.
ObjC = 0,

/// Uses Swift protocol witness table dispatch.
///
/// To invoke methods of this protocol, a pointer to a protocol witness table
/// corresponding to the protocol conformance must be available.
Swift = 1,
};

/// Does a protocol using the given strategy require a witness table?
inline bool protocolRequiresWitnessTable(ProtocolDispatchStrategy strategy) {
switch (strategy) {
case ProtocolDispatchStrategy::ObjC:
return false;
case ProtocolDispatchStrategy::Swift:
return true;
}

swift_unreachable("Unhandled ProtocolDispatchStrategy in switch.");
}

}

#endif
28 changes: 17 additions & 11 deletions include/swift/AST/ASTScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,8 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
public:
PatternBindingDecl *const decl;
const unsigned patternEntryIndex;
const bool isLocalBinding;

AbstractPatternEntryScope(PatternBindingDecl *, unsigned entryIndex,
bool);
AbstractPatternEntryScope(PatternBindingDecl *, unsigned entryIndex);
virtual ~AbstractPatternEntryScope() {}

const PatternBindingEntry &getPatternEntry() const;
Expand All @@ -1041,10 +1039,14 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
};

class PatternEntryDeclScope final : public AbstractPatternEntryScope {
const bool isLocalBinding;
Optional<SourceLoc> endLoc;

public:
PatternEntryDeclScope(PatternBindingDecl *pbDecl, unsigned entryIndex,
bool isLocalBinding)
: AbstractPatternEntryScope(pbDecl, entryIndex, isLocalBinding) {}
bool isLocalBinding, Optional<SourceLoc> endLoc)
: AbstractPatternEntryScope(pbDecl, entryIndex),
isLocalBinding(isLocalBinding), endLoc(endLoc) {}
virtual ~PatternEntryDeclScope() {}

protected:
Expand All @@ -1070,9 +1072,8 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
Expr *initAsWrittenWhenCreated;

public:
PatternEntryInitializerScope(PatternBindingDecl *pbDecl, unsigned entryIndex,
bool isLocalBinding)
: AbstractPatternEntryScope(pbDecl, entryIndex, isLocalBinding),
PatternEntryInitializerScope(PatternBindingDecl *pbDecl, unsigned entryIndex)
: AbstractPatternEntryScope(pbDecl, entryIndex),
initAsWrittenWhenCreated(pbDecl->getOriginalInit(entryIndex)) {}
virtual ~PatternEntryInitializerScope() {}

Expand Down Expand Up @@ -1400,7 +1401,8 @@ class WhileStmtScope final : public LabeledConditionalStmtScope {
class GuardStmtScope final : public LabeledConditionalStmtScope {
public:
GuardStmt *const stmt;
GuardStmtScope(GuardStmt *e) : stmt(e) {}
SourceLoc endLoc;
GuardStmtScope(GuardStmt *e, SourceLoc endLoc) : stmt(e), endLoc(endLoc) {}
virtual ~GuardStmtScope() {}

protected:
Expand All @@ -1413,6 +1415,8 @@ class GuardStmtScope final : public LabeledConditionalStmtScope {
public:
std::string getClassName() const override;
LabeledConditionalStmt *getLabeledConditionalStmt() const override;
SourceRange
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
};

/// A scope after a guard statement that follows lookups into the conditions
Expand All @@ -1427,9 +1431,11 @@ class LookupParentDiversionScope final : public ASTScopeImpl {
public:
ASTScopeImpl *const lookupParent;
const SourceLoc startLoc;
const SourceLoc endLoc;

LookupParentDiversionScope(ASTScopeImpl *lookupParent, SourceLoc startLoc)
: lookupParent(lookupParent), startLoc(startLoc) {}
LookupParentDiversionScope(ASTScopeImpl *lookupParent,
SourceLoc startLoc, SourceLoc endLoc)
: lookupParent(lookupParent), startLoc(startLoc), endLoc(endLoc) {}

SourceRange
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
Expand Down
49 changes: 49 additions & 0 deletions include/swift/Basic/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,59 @@
#define SWIFT_ASSUME(x)
#endif

/// Attributes.

#if __has_attribute(constructor)
#define SWIFT_CONSTRUCTOR __attribute__((constructor))
#else
#define SWIFT_CONSTRUCTOR
#endif

/// \macro SWIFT_GNUC_PREREQ
/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't
/// available.
#ifndef SWIFT_GNUC_PREREQ
# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
# define SWIFT_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
((maj) << 20) + ((min) << 10) + (patch))
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
# define SWIFT_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
# else
# define SWIFT_GNUC_PREREQ(maj, min, patch) 0
# endif
#endif


/// SWIFT_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so,
/// mark a method "not for inlining".
#if __has_attribute(noinline) || SWIFT_GNUC_PREREQ(3, 4, 0)
#define SWIFT_ATTRIBUTE_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
#define SWIFT_ATTRIBUTE_NOINLINE __declspec(noinline)
#else
#define SWIFT_ATTRIBUTE_NOINLINE
#endif

/// SWIFT_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do
/// so, mark a method "always inline" because it is performance sensitive. GCC
/// 3.4 supported this but is buggy in various cases and produces unimplemented
/// errors, just use it in GCC 4.0 and later.
#if __has_attribute(always_inline) || SWIFT_GNUC_PREREQ(4, 0, 0)
#define SWIFT_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
#elif defined(_MSC_VER)
#define SWIFT_ATTRIBUTE_ALWAYS_INLINE __forceinline
#else
#define SWIFT_ATTRIBUTE_ALWAYS_INLINE
#endif

#ifdef __GNUC__
#define SWIFT_ATTRIBUTE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
#define SWIFT_ATTRIBUTE_NORETURN __declspec(noreturn)
#else
#define SWIFT_ATTRIBUTE_NORETURN
#endif

#endif // SWIFT_BASIC_COMPILER_H
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- Unreachable.h - Implements swift_runtime_unreachable ---*- C++ -*-===//
//===--- Unreachable.h - Implements swift_unreachable ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
Expand All @@ -10,24 +10,38 @@
//
//===----------------------------------------------------------------------===//
//
// This file defines swift_runtime_unreachable, an LLVM-independent
// implementation of llvm_unreachable.
// This file defines swift_unreachable, which provides the
// functionality of llvm_unreachable without necessarily depending on
// the LLVM support libraries.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_RUNTIME_UNREACHABLE_H
#define SWIFT_RUNTIME_UNREACHABLE_H
#ifndef SWIFT_BASIC_UNREACHABLE_H
#define SWIFT_BASIC_UNREACHABLE_H

#ifdef SWIFT_LLVM_SUPPORT_IS_AVAILABLE

// The implementation when LLVM is available.

#include "llvm/Support/ErrorHandling.h"
#define swift_unreachable llvm_unreachable

#else

// The implementation when LLVM is not available.

#include <assert.h>
#include <stdlib.h>

#include "swift/Runtime/Config.h"

SWIFT_RUNTIME_ATTRIBUTE_NORETURN
inline static void swift_runtime_unreachable(const char *msg) {
inline static void swift_unreachable(const char *msg) {
assert(false && msg);
(void)msg;
abort();
}

#endif // SWIFT_RUNTIME_UNREACHABLE_H
#endif

#endif
2 changes: 1 addition & 1 deletion include/swift/Demangling/TypeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "swift/Demangling/Demangler.h"
#include "swift/Demangling/NamespaceMacros.h"
#include "swift/Runtime/Portability.h"
#include "swift/Runtime/Unreachable.h"
#include "swift/Basic/Unreachable.h"
#include "swift/Strings.h"
#include "llvm/ADT/ArrayRef.h"
#include <vector>
Expand Down
6 changes: 5 additions & 1 deletion include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,11 @@ def scan_clang_dependencies : Flag<["-"], "scan-clang-dependencies">,

def disable_parser_lookup : Flag<["-"], "disable-parser-lookup">,
Flags<[FrontendOption]>,
HelpText<"Disable parser lookup & use ast scope lookup only (experimental)">;
HelpText<"Disable parser lookup & use ASTScope lookup only (experimental)">;

def enable_parser_lookup : Flag<["-"], "enable-parser-lookup">,
Flags<[FrontendOption]>,
HelpText<"Enable parser lookup">;

def enable_request_based_incremental_dependencies : Flag<["-"],
"enable-request-based-incremental-dependencies">,
Expand Down
Loading