Skip to content

Commit f50744e

Browse files
committed
---
yaml --- r: 268287 b: refs/heads/marcrasi-const-evaluator-part-2 c: 0faf870 h: refs/heads/master i: 268285: 4a91f61 268283: 26823a0 268279: b95b6ed 268271: b60479c 268255: 2a137cb 268223: 7c4cb07 268159: 25b954d 268031: 7454950 267775: d381b47 267263: 4a11404 266239: d4f560f
1 parent 452fb95 commit f50744e

28 files changed

+347
-442
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-09-28-a: c30bf9b3ca148b1b90ebcd80141d9
10811081
refs/heads/bananaphone: 2af9a1dc7f40dcb4b2949876f7e237763d1a7972
10821082
refs/heads/marcrasi-const-evaluator-part-3: 867d96d6aa4cfb5079b7478be617387a1f621c88
10831083
refs/heads/marcrasi-const-evaluator-part-1: 390daeaeea2181a1fc24910e09b5861053cd3558
1084-
refs/heads/marcrasi-const-evaluator-part-2: f521e1d395e2c1b1f82e8e59049c0300fca258aa
1084+
refs/heads/marcrasi-const-evaluator-part-2: 0faf87008c3f88610359c722f2df9286f28958a4
10851085
refs/heads/revert-19689-keep-sourcekitd-response-alive-while-variant-lives: b5b1d9ab2340a64a3c7332529cdca1cb2318d93c
10861086
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-01-a: 63059bdab8bbcdd68591738fa28c68c8c19bde75
10871087
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-02-a: 12514879eff2c34a64ac6e65b323447f6525cfd0

branches/marcrasi-const-evaluator-part-2/benchmark/scripts/run_smoke_bench

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
139139
new_lines = ""
140140

141141
# #,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs),PEAK_MEMORY(B)
142-
score_re = re.compile(r"(\d+),([\w.\-]+),\d+,(\d+)")
142+
score_re = re.compile(r"(\d+),(\w+),\d+,(\d+)")
143143

144144
while to_test is None or len(to_test) > 0:
145145
tested_benchmarks = set()
@@ -221,8 +221,7 @@ def get_results(bench_dir, opt_level, num_samples, to_test):
221221
if to_test:
222222
args += to_test
223223
env = {'DYLD_LIBRARY_PATH': os.path.join(bench_dir, 'lib', 'swift',
224-
'macos'),
225-
'SWIFT_DETERMINISTIC_HASHING': '1'}
224+
'macos')}
226225
output = subprocess.check_output(args, env=env)
227226
except subprocess.CalledProcessError as e:
228227
sys.stderr.write(e.output)

branches/marcrasi-const-evaluator-part-2/benchmark/scripts/run_smoke_bench.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def log_filename(bench_dir):
9696
new_logf = open(log_filename(new_dir), 'w')
9797

9898
# #,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs),PEAK_MEMORY(B)
99-
score_re = re.compile(r"(\d+),([\w.\-]+),\d+,(\d+)")
99+
score_re = re.compile(r"(\d+),(\w+),\d+,(\d+)")
100100

101101
while to_test is None or len(to_test) > 0:
102102
tested_benchmarks = set()
@@ -180,8 +180,7 @@ def get_results(bench_dir, opt_level, num_samples, to_test):
180180
if to_test:
181181
args += to_test
182182
env = {'DYLD_LIBRARY_PATH': os.path.join(bench_dir, 'lib', 'swift',
183-
'macos'),
184-
'SWIFT_DETERMINISTIC_HASHING': '1'}
183+
'macos')}
185184
output = subprocess.check_output(args, env=env)
186185
except subprocess.CalledProcessError as e:
187186
sys.stderr.write(e.output)

branches/marcrasi-const-evaluator-part-2/docs/WindowsBuild.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,24 @@ popd
106106
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64/"
107107
```
108108

109-
### 6. Build LLVM/Clang
109+
### 6. Build LLVM/Clang/Compiler-RT
110110
- This must be done from within a developer command prompt. LLVM and Clang are
111111
large projects, so building might take a few hours. Make sure that the build
112112
type (e.g. `Debug`, `Release`, `RelWithDebInfoAssert`) for LLVM/Clang matches the
113113
build type for Swift.
114+
- Optionally, you can omit building compiler-rt by removing all lines referring
115+
to `compiler-rt` below, which should give faster build times.
114116
```cmd
117+
mklink /J "%swift_source_dir%/llvm/tools/compiler-rt" "%swift_source_dir%/compiler-rt"
115118
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
116119
pushd "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
117120
cmake -G "Ninja"^
118121
-DLLVM_ENABLE_ASSERTIONS=TRUE^
119122
-DCMAKE_BUILD_TYPE=Debug^
120123
-DLLVM_TOOL_SWIFT_BUILD=NO^
121124
-DLLVM_INCLUDE_DOCS=TRUE^
125+
-DLLVM_TOOL_COMPILER_RT_BUILD=TRUE^
126+
-DLLVM_BUILD_EXTERNAL_COMPILER_RT=TRUE^
122127
-DLLVM_ENABLE_PROJECTS=clang^
123128
-DLLVM_LIT_ARGS=-sv^
124129
-DLLVM_TARGETS_TO_BUILD=X86^

branches/marcrasi-const-evaluator-part-2/include/swift/Basic/Lazy.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ template <class T> class Lazy {
5858

5959
T &get(void (*initCallback)(void *) = defaultInitCallback);
6060

61-
template<typename Arg1>
62-
T &getWithInit(Arg1 &&arg1);
63-
6461
/// Get the value, assuming it must have already been initialized by this
6562
/// point.
6663
T &unsafeGetAlreadyInitialized() { return *reinterpret_cast<T *>(&Value); }
@@ -83,22 +80,6 @@ template <typename T> inline T &Lazy<T>::get(void (*initCallback)(void*)) {
8380
return unsafeGetAlreadyInitialized();
8481
}
8582

86-
template <typename T>
87-
template <typename Arg1> inline T &Lazy<T>::getWithInit(Arg1 &&arg1) {
88-
struct Data {
89-
void *address;
90-
Arg1 &&arg1;
91-
92-
static void init(void *context) {
93-
Data *data = static_cast<Data *>(context);
94-
::new (data->address) T(static_cast<Arg1&&>(data->arg1));
95-
}
96-
} data{&Value, static_cast<Arg1&&>(arg1)};
97-
98-
SWIFT_ONCE_F(OnceToken, &Data::init, &data);
99-
return unsafeGetAlreadyInitialized();
100-
}
101-
10283
} // end namespace swift
10384

10485
#define SWIFT_LAZY_CONSTANT(INITIAL_VALUE) \

branches/marcrasi-const-evaluator-part-2/include/swift/Basic/SourceLoc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class CharSourceRange {
132132
/// \brief Constructs an invalid range.
133133
CharSourceRange() = default;
134134

135+
CharSourceRange &operator=(const CharSourceRange &) = default;
136+
135137
CharSourceRange(SourceLoc Start, unsigned ByteLength)
136138
: Start(Start), ByteLength(ByteLength) {}
137139

branches/marcrasi-const-evaluator-part-2/include/swift/Basic/TreeScopedHashTable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ template <typename K, typename V> class TreeScopedHashTableVal {
3737
TreeScopedHashTableVal(const K &Key, const V &Val) : Key(Key), Val(Val) {}
3838

3939
public:
40-
~TreeScopedHashTableVal() = default;
4140
TreeScopedHashTableVal(const TreeScopedHashTableVal &) = delete;
4241
TreeScopedHashTableVal(TreeScopedHashTableVal &&) = delete;
4342
TreeScopedHashTableVal &operator=(const TreeScopedHashTableVal &) = delete;

branches/marcrasi-const-evaluator-part-2/include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939

4040
/// Get the metadata version supported by the Remote Mirror library.
4141
SWIFT_REMOTE_MIRROR_LINKAGE
42-
uint16_t swift_reflection_getSupportedMetadataVersion(void);
42+
uint16_t swift_reflection_getSupportedMetadataVersion();
4343

4444
/// \returns An opaque reflection context.
4545
SWIFT_REMOTE_MIRROR_LINKAGE

branches/marcrasi-const-evaluator-part-2/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h

Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "SwiftRemoteMirrorLegacyInteropTypes.h"
2626
#include "SwiftRemoteMirror.h"
2727

28-
#include <string.h>
2928
#include <dlfcn.h>
3029
#include <mach-o/getsect.h>
3130

@@ -38,19 +37,14 @@
3837
static inline SwiftReflectionInteropContextRef
3938
swift_reflection_interop_createReflectionContext(
4039
void *ReaderContext,
40+
void *LibraryHandle,
41+
void *LegacyLibraryHandle,
4142
uint8_t PointerSize,
4243
FreeBytesFunction FreeBytes,
4344
ReadBytesFunction ReadBytes,
4445
GetStringLengthFunction GetStringLength,
4546
GetSymbolAddressFunction GetSymbolAddress);
4647

47-
/// Add a library handle to the interop context. Returns 1 if the
48-
/// library was added successfully, 0 if a symbol couldn't be looked up
49-
/// or the reported metadata version is too old.
50-
static inline int
51-
swift_reflection_interop_addLibrary(
52-
SwiftReflectionInteropContextRef ContextRef, void *LibraryHandle);
53-
5448
static inline void
5549
swift_reflection_interop_destroyReflectionContext(
5650
SwiftReflectionInteropContextRef ContextRef);
@@ -289,7 +283,6 @@ struct SwiftReflectionInteropContextLegacyImageRangeList {
289283

290284
struct SwiftReflectionInteropContext {
291285
void *ReaderContext;
292-
uint8_t PointerSize;
293286
FreeBytesFunction FreeBytes;
294287
ReadBytesFunction ReadBytes;
295288
uint64_t (*GetStringLength)(void *reader_context,
@@ -298,7 +291,8 @@ struct SwiftReflectionInteropContext {
298291
const char *name,
299292
uint64_t name_length);
300293

301-
struct SwiftReflectionInteropContextLibrary *Libraries;
294+
// Currently we support at most two libraries.
295+
struct SwiftReflectionInteropContextLibrary Libraries[2];
302296
int LibraryCount;
303297

304298
struct SwiftReflectionInteropContextFreeList *FreeList;
@@ -387,11 +381,12 @@ swift_reflection_interop_libraryForObject(
387381
return swift_reflection_interop_libraryForAddress(ContextRef, Metadata);
388382
}
389383

390-
static inline int
384+
static inline void
391385
swift_reflection_interop_loadFunctions(struct SwiftReflectionInteropContext *Context,
392-
void *Handle) {
386+
void *Handle,
387+
int IsLegacy) {
393388
if (Handle == NULL)
394-
return 0;
389+
return;
395390

396391
struct SwiftReflectionInteropContextLibrary *Library = &Context
397392
->Libraries[Context->LibraryCount];
@@ -402,16 +397,14 @@ swift_reflection_interop_loadFunctions(struct SwiftReflectionInteropContext *Con
402397
#endif
403398
#define LOAD_NAMED(field, symbol) do { \
404399
Functions->field = (decltype(Functions->field))dlsym(Handle, symbol); \
405-
if (Functions->field == NULL) return 0; \
400+
if (Functions->field == NULL) return; \
406401
} while (0)
407402
#define LOAD(name) LOAD_NAMED(name, "swift_reflection_" #name)
408403

409404
LOAD(getSupportedMetadataVersion);
410405
uint16_t version = Functions->getSupportedMetadataVersion();
411406
if (version < SWIFT_LEGACY_METADATA_MIN_VERSION)
412-
return 0;
413-
414-
int IsLegacy = dlsym(Handle, "swift_reflection_addImage") == NULL;
407+
return;
415408

416409
if (IsLegacy) {
417410
LOAD_NAMED(createReflectionContextLegacy, "swift_reflection_createReflectionContext");
@@ -445,7 +438,7 @@ swift_reflection_interop_loadFunctions(struct SwiftReflectionInteropContext *Con
445438
Library->IsLegacy = IsLegacy;
446439
Context->LibraryCount++;
447440

448-
return 1;
441+
return;
449442

450443
#undef LOAD
451444
#undef LOAD_NAMED
@@ -477,7 +470,6 @@ swift_reflection_interop_readBytesAdapter(void *reader_context,
477470
static inline uint8_t
478471
swift_reflection_interop_getSizeAdapter(void *reader_context) {
479472
// Legacy library doesn't pay attention to these anyway.
480-
(void)reader_context;
481473
return sizeof(void *);
482474
}
483475

@@ -500,6 +492,8 @@ swift_reflection_interop_GetSymbolAddressAdapter(
500492
static inline SwiftReflectionInteropContextRef
501493
swift_reflection_interop_createReflectionContext(
502494
void *ReaderContext,
495+
void *LibraryHandle,
496+
void *LegacyLibraryHandle,
503497
uint8_t PointerSize,
504498
FreeBytesFunction FreeBytes,
505499
ReadBytesFunction ReadBytes,
@@ -509,27 +503,15 @@ swift_reflection_interop_createReflectionContext(
509503
SwiftReflectionInteropContextRef ContextRef =
510504
(SwiftReflectionInteropContextRef)calloc(sizeof(*ContextRef), 1);
511505

512-
ContextRef->ReaderContext = ReaderContext;
513-
ContextRef->PointerSize = PointerSize;
514-
ContextRef->FreeBytes = FreeBytes;
515-
ContextRef->ReadBytes = ReadBytes;
516-
ContextRef->GetStringLength = GetStringLength;
517-
ContextRef->GetSymbolAddress = GetSymbolAddress;
506+
swift_reflection_interop_loadFunctions(ContextRef, LibraryHandle, 0);
507+
swift_reflection_interop_loadFunctions(ContextRef, LegacyLibraryHandle, 1);
518508

519-
ContextRef->AddressToLibraryCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
509+
if (ContextRef->LibraryCount == 0) {
510+
free(ContextRef);
511+
return NULL;
512+
}
520513

521-
return ContextRef;
522-
}
523-
524-
static inline int
525-
swift_reflection_interop_addLibrary(
526-
SwiftReflectionInteropContextRef ContextRef, void *LibraryHandle) {
527-
size_t NewSize = (ContextRef->LibraryCount + 1) * sizeof(*ContextRef->Libraries);
528-
ContextRef->Libraries = realloc(ContextRef->Libraries, NewSize);
529-
int Success = swift_reflection_interop_loadFunctions(ContextRef, LibraryHandle);
530-
if (Success) {
531-
struct SwiftReflectionInteropContextLibrary *Library =
532-
&ContextRef->Libraries[ContextRef->LibraryCount - 1];
514+
FOREACH_LIBRARY {
533515
if (Library->IsLegacy) {
534516
Library->Context = Library->Functions.createReflectionContextLegacy(
535517
ContextRef,
@@ -538,12 +520,20 @@ swift_reflection_interop_addLibrary(
538520
swift_reflection_interop_GetStringLengthAdapter,
539521
swift_reflection_interop_GetSymbolAddressAdapter);
540522
} else {
541-
Library->Context = Library->Functions.createReflectionContext(
542-
ContextRef->ReaderContext,
543-
ContextRef->PointerSize, ContextRef->FreeBytes, ContextRef->ReadBytes, ContextRef->GetStringLength, ContextRef->GetSymbolAddress);
523+
Library->Context = Library->Functions.createReflectionContext(ReaderContext,
524+
PointerSize, FreeBytes, ReadBytes, GetStringLength, GetSymbolAddress);
544525
}
545526
}
546-
return Success;
527+
528+
ContextRef->ReaderContext = ReaderContext;
529+
ContextRef->FreeBytes = FreeBytes;
530+
ContextRef->ReadBytes = ReadBytes;
531+
ContextRef->GetStringLength = GetStringLength;
532+
ContextRef->GetSymbolAddress = GetSymbolAddress;
533+
534+
ContextRef->AddressToLibraryCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
535+
536+
return ContextRef;
547537
}
548538

549539
static inline void
@@ -552,7 +542,6 @@ swift_reflection_interop_destroyReflectionContext(
552542
FOREACH_LIBRARY {
553543
Library->Functions.destroyReflectionContext(Library->Context);
554544
}
555-
free(ContextRef->Libraries);
556545
struct SwiftReflectionInteropContextLegacyImageRangeList *LegacyImageRangeList
557546
= ContextRef->LegacyImageRangeList;
558547
while (LegacyImageRangeList != NULL) {
@@ -679,14 +668,14 @@ swift_reflection_interop_addImageLegacy(
679668
}
680669

681670
info.LocalStartAddress = (uintptr_t)Buf;
682-
info.RemoteStartAddress = (uintptr_t)ImageStart;
671+
info.RemoteStartAddress = ImageStart;
683672

684673
Library->Functions.addReflectionInfoLegacy(Library->Context, info);
685674

686675
// Find the data segment and add it to our list.
687676
unsigned long DataSize;
688677
const uint8_t *DataSegment = getsegmentdata(Header, "__DATA", &DataSize);
689-
uintptr_t DataSegmentStart = (uintptr_t)(DataSegment - (const uint8_t *)Buf + ImageStart);
678+
uintptr_t DataSegmentStart = DataSegment - (const uint8_t *)Buf + ImageStart;
690679

691680
struct SwiftReflectionInteropContextLegacyImageRangeList *Node =
692681
(struct SwiftReflectionInteropContextLegacyImageRangeList *)malloc(sizeof(*Node));
@@ -698,12 +687,12 @@ swift_reflection_interop_addImageLegacy(
698687
// If the buffer needs to be freed, save buffer and free context to free it when the
699688
// reflection context is destroyed.
700689
if (ContextRef->FreeBytes != NULL) {
701-
struct SwiftReflectionInteropContextFreeList *FreeListNode =
702-
(struct SwiftReflectionInteropContextFreeList *)malloc(sizeof(*FreeListNode));
703-
FreeListNode->Next = ContextRef->FreeList;
704-
FreeListNode->Pointer = Buf;
705-
FreeListNode->Context = FreeContext;
706-
ContextRef->FreeList = FreeListNode;
690+
struct SwiftReflectionInteropContextFreeList *Node =
691+
(struct SwiftReflectionInteropContextFreeList *)malloc(sizeof(*Node));
692+
Node->Next = ContextRef->FreeList;
693+
Node->Pointer = Buf;
694+
Node->Context = FreeContext;
695+
ContextRef->FreeList = Node;
707696
}
708697

709698
return 1;
@@ -747,7 +736,7 @@ swift_reflection_interop_lookupMetadata(SwiftReflectionInteropContextRef Context
747736
swift_reflection_interop_libraryForAddress(ContextRef, Metadata);
748737
if (Library != NULL) {
749738
Result.Metadata = Metadata;
750-
Result.Library = (int)LIBRARY_INDEX;
739+
Result.Library = LIBRARY_INDEX;
751740
}
752741
return Result;
753742
}
@@ -773,7 +762,7 @@ swift_reflection_interop_typeRefForInstance(SwiftReflectionInteropContextRef Con
773762
swift_typeref_t Typeref = Library->Functions.typeRefForInstance(Library->Context,
774763
Object);
775764
Result.Typeref = Typeref;
776-
Result.Library = (int)LIBRARY_INDEX;
765+
Result.Library = LIBRARY_INDEX;
777766
}
778767
return Result;
779768
}
@@ -791,7 +780,7 @@ swift_reflection_interop_typeRefForMangledTypeName(
791780
continue;
792781

793782
Result.Typeref = Typeref;
794-
Result.Library = (int)LIBRARY_INDEX;
783+
Result.Library = LIBRARY_INDEX;
795784
return Result;
796785
}
797786

@@ -878,7 +867,7 @@ swift_reflection_interop_childOfInstance(SwiftReflectionInteropContextRef Contex
878867
Result.Offset = LibResult.Offset;
879868
Result.Kind = LibResult.Kind;
880869
Result.TR.Typeref = LibResult.TR;
881-
Result.TR.Library = (int)LIBRARY_INDEX;
870+
Result.TR.Library = LIBRARY_INDEX;
882871
} else {
883872
Result.Kind = SWIFT_UNKNOWN;
884873
}

branches/marcrasi-const-evaluator-part-2/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ typedef enum swift_layout_kind {
108108

109109
// References to other objects in the heap.
110110
SWIFT_STRONG_REFERENCE,
111-
SWIFT_UNOWNED_REFERENCE,
112-
SWIFT_WEAK_REFERENCE,
113-
SWIFT_UNMANAGED_REFERENCE,
111+
#define REF_STORAGE(Name, name, NAME) \
112+
SWIFT_##NAME##_REFERENCE,
113+
#include "swift/AST/ReferenceStorage.def"
114114

115115
// Layouts of heap objects. These are only ever returned from
116116
// swift_reflection_infoFor{Instance,Metadata}(), and not

0 commit comments

Comments
 (0)