Skip to content

Commit 3c9a059

Browse files
authored
---
yaml --- r: 348957 b: refs/heads/master c: 54ec600 h: refs/heads/master i: 348955: 67d5a4e
1 parent 37b9276 commit 3c9a059

File tree

9 files changed

+79
-34
lines changed

9 files changed

+79
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4bafc7718e3c155999806b0b3103088fffde4bdb
2+
refs/heads/master: 54ec600c11e3252011faa3ad5932b55e41372c83
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ function(_compile_swift_files
333333
"-emit-module-interface-path" "${interface_file}")
334334
endif()
335335

336+
if (NOT SWIFTFILE_IS_STDLIB_CORE)
337+
list(APPEND swift_module_flags
338+
"-Xfrontend" "-experimental-skip-non-inlinable-function-bodies")
339+
endif()
340+
336341
# If we have extra regexp flags, check if we match any of the regexps. If so
337342
# add the relevant flags to our swift_flags.
338343
if (SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS OR SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS)

trunk/lib/IRGen/LoadableByAddress.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,20 @@ static void convertBBArgType(SILBuilder &argBuilder, SILType newSILType,
14261426
}
14271427
}
14281428

1429+
static bool containsFunctionType(CanType ty) {
1430+
if (auto tuple = dyn_cast<TupleType>(ty)) {
1431+
for (auto elt : tuple.getElementTypes()) {
1432+
if (containsFunctionType(elt))
1433+
return true;
1434+
}
1435+
return false;
1436+
}
1437+
if (auto optionalType = ty.getOptionalObjectType()) {
1438+
return containsFunctionType(optionalType);
1439+
}
1440+
return isa<SILFunctionType>(ty);
1441+
}
1442+
14291443
void LoadableStorageAllocation::convertApplyResults() {
14301444
for (auto &BB : *pass.F) {
14311445
for (auto &II : BB) {
@@ -1450,16 +1464,7 @@ void LoadableStorageAllocation::convertApplyResults() {
14501464
auto numFuncTy = llvm::count_if(origSILFunctionType->getResults(),
14511465
[](const SILResultInfo &origResult) {
14521466
auto resultStorageTy = origResult.getSILStorageType();
1453-
// Check if it is a function type
1454-
if (resultStorageTy.is<SILFunctionType>()) {
1455-
return true;
1456-
}
1457-
// Check if it is an optional function type
1458-
auto optionalType = resultStorageTy.getOptionalObjectType();
1459-
if (optionalType && optionalType.is<SILFunctionType>()) {
1460-
return true;
1461-
}
1462-
return false;
1467+
return containsFunctionType(resultStorageTy.getASTType());
14631468
});
14641469
assert(numFuncTy != 0 &&
14651470
"Expected a SILFunctionType inside the result Type");

trunk/stdlib/public/runtime/HeapObject.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ static inline bool isValidPointerForNativeRetain(const void *p) {
7272
#endif
7373
}
7474

75+
// Call the appropriate implementation of the `name` function, passing `args`
76+
// to the call. This checks for an override in the function pointer. If an
77+
// override is present, it calls that override. Otherwise it directly calls
78+
// the default implementation. This allows the compiler to inline the default
79+
// implementation and avoid the performance penalty of indirecting through
80+
// the function pointer in the common case.
81+
#define CALL_IMPL(name, args) do { \
82+
if (SWIFT_UNLIKELY(_ ## name != _ ## name ## _)) \
83+
return _ ## name args; \
84+
return _ ## name ## _ args; \
85+
} while(0)
86+
87+
7588
static HeapObject *_swift_allocObject_(HeapMetadata const *metadata,
7689
size_t requiredSize,
7790
size_t requiredAlignmentMask) {
@@ -95,9 +108,7 @@ static HeapObject *_swift_allocObject_(HeapMetadata const *metadata,
95108
HeapObject *swift::swift_allocObject(HeapMetadata const *metadata,
96109
size_t requiredSize,
97110
size_t requiredAlignmentMask) {
98-
if (SWIFT_UNLIKELY(_swift_allocObject != _swift_allocObject_))
99-
return _swift_allocObject(metadata, requiredSize, requiredAlignmentMask);
100-
return _swift_allocObject_(metadata, requiredSize, requiredAlignmentMask);
111+
CALL_IMPL(swift_allocObject, (metadata, requiredSize, requiredAlignmentMask));
101112
}
102113

103114
HeapObject *(*swift::_swift_allocObject)(HeapMetadata const *metadata,
@@ -305,9 +316,7 @@ static HeapObject *_swift_retain_(HeapObject *object) {
305316
}
306317

307318
HeapObject *swift::swift_retain(HeapObject *object) {
308-
if (SWIFT_UNLIKELY(_swift_retain != _swift_retain_))
309-
return _swift_retain(object);
310-
return _swift_retain_(object);
319+
CALL_IMPL(swift_retain, (object));
311320
}
312321

313322
HeapObject *(*swift::_swift_retain)(HeapObject *object) = _swift_retain_;
@@ -327,9 +336,7 @@ static HeapObject *_swift_retain_n_(HeapObject *object, uint32_t n) {
327336
}
328337

329338
HeapObject *swift::swift_retain_n(HeapObject *object, uint32_t n) {
330-
if (SWIFT_UNLIKELY(_swift_retain_n != _swift_retain_n_))
331-
return _swift_retain_n(object, n);
332-
return _swift_retain_n_(object, n);
339+
CALL_IMPL(swift_retain_n, (object, n));
333340
}
334341

335342
HeapObject *(*swift::_swift_retain_n)(HeapObject *object, uint32_t n) =
@@ -349,9 +356,7 @@ static void _swift_release_(HeapObject *object) {
349356
}
350357

351358
void swift::swift_release(HeapObject *object) {
352-
if (SWIFT_UNLIKELY(_swift_release != _swift_release_))
353-
_swift_release(object);
354-
_swift_release_(object);
359+
CALL_IMPL(swift_release, (object));
355360
}
356361

357362
void (*swift::_swift_release)(HeapObject *object) = _swift_release_;
@@ -369,9 +374,7 @@ static void _swift_release_n_(HeapObject *object, uint32_t n) {
369374
}
370375

371376
void swift::swift_release_n(HeapObject *object, uint32_t n) {
372-
if (SWIFT_UNLIKELY(_swift_release_n != _swift_release_n_))
373-
return _swift_release_n(object, n);
374-
return _swift_release_n_(object, n);
377+
CALL_IMPL(swift_release_n, (object, n));
375378
}
376379

377380
void (*swift::_swift_release_n)(HeapObject *object, uint32_t n) =
@@ -509,9 +512,7 @@ static HeapObject *_swift_tryRetain_(HeapObject *object) {
509512
}
510513

511514
HeapObject *swift::swift_tryRetain(HeapObject *object) {
512-
if (SWIFT_UNLIKELY(_swift_tryRetain != _swift_tryRetain_))
513-
return _swift_tryRetain(object);
514-
return _swift_tryRetain_(object);
515+
CALL_IMPL(swift_tryRetain, (object));
515516
}
516517

517518
HeapObject *(*swift::_swift_tryRetain)(HeapObject *object) = _swift_tryRetain_;

trunk/stdlib/toolchain/Compatibility50/ProtocolConformance.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "Overrides.h"
2121
#include "../../public/runtime/Private.h"
2222
#include "swift/Basic/Lazy.h"
23+
#include <dlfcn.h>
2324
#include <mach-o/dyld.h>
2425
#include <mach-o/getsect.h>
2526
#include <objc/runtime.h>
@@ -89,13 +90,25 @@ static void registerAddImageCallback(void *) {
8990
_dyld_register_func_for_add_image(addImageCallback);
9091
}
9192

93+
static const Metadata *getObjCClassMetadata(const ClassMetadata *c) {
94+
// Look up swift_getObjCClassMetadata dynamically. This handles the case
95+
// where the main executable can't link against libswiftCore.dylib because
96+
// it will be loaded dynamically from a location that isn't known at build
97+
// time.
98+
using FPtr = const Metadata *(*)(const ClassMetadata *);
99+
FPtr func = SWIFT_LAZY_CONSTANT(
100+
reinterpret_cast<FPtr>(dlsym(RTLD_DEFAULT, "swift_getObjCClassMetadata")));
101+
102+
return func(c);
103+
}
104+
92105
// Clone of private helper swift::_swiftoverride_class_getSuperclass
93106
// for use in the override implementation.
94107
static const Metadata *_swift50override_class_getSuperclass(
95108
const Metadata *theClass) {
96109
if (const ClassMetadata *classType = theClass->getClassObject()) {
97110
if (classHasSuperclass(classType))
98-
return getMetadataForClass(classType->Superclass);
111+
return getObjCClassMetadata(classType->Superclass);
99112
}
100113

101114
if (const ForeignClassMetadata *foreignClassType

trunk/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ foreach(SDK ${SWIFT_SDKS})
205205

206206
# NOTE create a stub BlocksRuntime library that can be used for the
207207
# reflection tests
208-
file(WRITE ${test_bin_dir}/BlocksRuntime.c
208+
file(WRITE ${test_bin_dir}/Inputs/BlocksRuntime.c
209209
"void
210210
#if defined(_WIN32)
211211
__declspec(dllexport)
@@ -220,7 +220,7 @@ _Block_release(void) { }\n")
220220
ARCHITECTURE ${ARCH}
221221
SDK ${SDK}
222222
INSTALL_IN_COMPONENT dev
223-
${test_bin_dir}/BlocksRuntime.c)
223+
${test_bin_dir}/Inputs/BlocksRuntime.c)
224224
set_target_properties(BlocksRuntimeStub${VARIANT_SUFFIX} PROPERTIES
225225
ARCHIVE_OUTPUT_DIRECTORY ${test_bin_dir}
226226
LIBRARY_OUTPUT_DIRECTORY ${test_bin_dir}

trunk/test/IRGen/big_types_corner_cases.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,11 @@ public extension sr8076_QueryHandler {
346346
return try body(query)
347347
}
348348
}
349+
350+
public func foo() -> Optional<(a: Int?, b: Bool, c: (Int?)->BigStruct?)> {
351+
return nil
352+
}
353+
354+
public func dontAssert() {
355+
let _ = foo()
356+
}

trunk/test/lit.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode,
178178
execute_external=not use_lit_shell)
179179

180180
# suffixes: A list of file extensions to treat as test files.
181-
config.suffixes = ['.swift', '.ll', '.sil', '.gyb', '.m', '.swiftinterface',
182-
'.test-sh']
181+
config.suffixes = ['.swift', '.ll', '.sil', '.gyb', '.m', '.c',
182+
'.swiftinterface', '.test-sh']
183183

184184
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
185185
# subdirectories contain auxiliary inputs for various tests in their parent
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-clang %s -all_load %test-resource-dir/%target-sdk-name/libswiftCompatibility50.a -lobjc -o %t/main
3+
// RUN: %target-run %t/main
4+
// REQUIRES: objc_interop
5+
// REQUIRES: executable_test
6+
7+
// The compatibility library needs to have no build-time dependencies on
8+
// libswiftCore so it can be linked into a program that doesn't link
9+
// libswiftCore, but will load it at runtime, such as xctest.
10+
//
11+
// Test this by linking it into a plain C program and making sure it builds.
12+
13+
int main(void) {}

0 commit comments

Comments
 (0)