profile
viewpoint

mikeash/MAKVONotificationCenter 529

Better key-value observing for Cocoa

mikeash/MABlockClosure 323

ObjC block -> C function pointer using libffi

mikeash/MACollectionUtilities 247

Smalltalk-inspired collection utility methods and macros for Cocoa

mikeash/BinaryCoder 153

An example implementation of Swift.Codable using a simple binary format

mikeash/MADispatchQueue 120

A spiritual reimplementation of the basics of dispatch_queue, for educational purposes

mikeash/MAFuture 86

Proxying futures library for Objective-C

mikeash/MAAsyncIO 84

GCD-based async IO

mikeash/MABGTimer 67

Background timers, not associated with any thread, for Objective-C

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

The new table spills out of the available space when targeting 32-bit. Working out how to shrink it further...

mikeash

comment created time in an hour

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

@swift-ci please test

mikeash

comment created time in 20 hours

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

I changed that copying hash_value function to use TransformRange instead. I also got the performance up to par by adding a cache for the most recently looked up type and doing a quick check for a repeated lookup before doing a full lookup, like ConcurrentMap does.

mikeash

comment created time in 20 hours

push eventmikeash/swift

Mike Ash

commit sha 4caf9f7a5c2a5aae8d48187b992cf03164c433f3

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap. Use StableAddressConcurrentReadableHashMap for now. MetadataCacheEntry's methods for awaiting a particular state assume a stable address, where it will repeatedly examine `this` in a loop while waiting on a condition variable, so we give it a stable address to accommodate that. This code can be changed to perform the necessary table lookup each time through the loop instead, and thus allow us to use a plain ConcurrentReadableHashMap and avoid the extra indirection, and I'll take care of that in a followup. rdar://problem/70220660

view details

Mike Ash

commit sha 1b59c5284f7f3ca947ddbdf3beb0e781747bcb3b

Have StableAddressConcurrentReadableHashMap remember the last found entry and check that before doing a more expensive lookup.

view details

push time in 20 hours

push eventmikeash/swift

Andrew Trick

commit sha 5eafc20cdd0ecebe30a2621f9e5f73b96de7c3a1

Fix undefined behavior in SmallString.withUTF8 withUTF8 currently vends a typed UInt8 pointer to the underlying SmallString. That pointer type differs from SmallString's representation. It should simply vend a raw pointer, which would be both type safe and convenient for UTF8 data. However, since this method is already @inlinable, I added calls to bindMemory to prevent the optimizer from reasoning about access to the typed pointer that we vend. rdar://67983613 (Undefinied behavior in SmallString.withUTF8 is miscompiled) Additional commentary: SmallString creates a situation where there are two types, the in-memory type, (UInt64, UInt64), vs. the element type, UInt8. `UnsafePointer<T>` specifies the in-memory type of the pointee, because that's how C works. If you want to specify an element type, not the in-memory type, then you need to use something other than UnsafePointer to view the memory. A trivial `BufferView<UInt8>` would be fine, although, frankly, I think UnsafeRawPointer is a perfectly good type on its own for UTF8 bytes. Unfortunately, a lot of the UTF8 helper code is ABI-exposed, so to work around this, we need to insert calls to bindMemory at strategic points to avoid undefined behavior. This is high-risk and can negatively affect performance. So far, I was able to resolve the regressions in our microbenchmarks just by tweaking the inliner.

view details

Andrew Trick

commit sha 42bf92a216a802b68bd071fb3f91e854be121295

Make bind_memory free to inline. bind_memory has no actual code size cost, and this is the only way to allow rebinding memory within critical standard library code like SmallString without regressing performance.

view details

Butta

commit sha 69d04aad08da3245f87c6a2df35869126d48b55e

[linux] remove absolute rpath of /usr/lib/swift/linux added to many shared libraries This was presumably added as a backup, in case the libraries in a toolchain couldn't be found, but will not work well, so take it out.

view details

Dave Lee

commit sha 27330f169df5d2dcb018ab2c6615d66be91d04e2

[build] Remove unused lldb cmake

view details

Keith Smiley

commit sha ae0c380f1b0f37e11b111a06634dd4c64e67b96c

Improve -*prefix-map help text Before: ``` -coverage-prefix-map <value> -debug-prefix-map <value> ``` After: ``` -coverage-prefix-map <prefix=replacement> -debug-prefix-map <prefix=replacement> ```

view details

Varun Gandhi

commit sha be109b72a576799a018dba368c8495d5a9f0d6e7

[AST] Add method to check if a function type has a non-trivial Clang type.

view details

Martin Boehme

commit sha a5e953b69009b59541420d06496206a26961a976

Add support for calling C++ constructors. Because C++ constructors always take a `this` pointer to the object to be initialized, we mark the SIL function return type with the `@out` attribute. On the IRGen side, we retrofit support for formal indirect return values as well as thin metatypes.

view details

Martin Boehme

commit sha 7ad2eef26508ad92d8d92f2d5546913c0ced3bbd

Only import constructors marked `noexcept`.

view details

Martin Boehme

commit sha 384854810a60a69c8df8a8c0248e209adc28c295

Revert "Only import constructors marked `noexcept`." This reverts commit 29650d8c1f302708a32304d49c703c9ddbf30b75. As discussed here, we want to import all constructors (whether they are marked `noexcept` or not) as non-throwing initializers; https://forums.swift.org/t/handling-c-exceptions/34823/50

view details

Martin Boehme

commit sha fd00bc1f01357ecd264b8216373c23014771c124

Move tests from `CXXInterop` to `Interop/Cxx`. This is the canonical location that we've agreed on.

view details

Martin Boehme

commit sha e6067275a6659cfab8640e68e93a5bba36ddca20

Duplicate changes to GenClangType in ClangTypeConverter. See discussion here: https://github.com/apple/swift/pull/30630#discussion_r398967412

view details

Martin Boehme

commit sha b2c5a3eeed4e0d80c819f98c816481fbedc49526

Add a constructor thunk if required to add additional constructor arguments. Also add more IR tests and make various other changes.

view details

Martin Boehme

commit sha 3066e16c37e26a5fea370877409b4d0bd1c0fea6

Remove redundant "cxx" from test names.

view details

Martin Boehme

commit sha 5644137ea0696164c5b5835179b1ec450d508c88

Eliminate duplication of code for adding empty argument names.

view details

Martin Boehme

commit sha bed26039446c189a82c453126e0a622e43c6256d

Various changes after merging master: - Adapt tests to changes that have happened in the meantime (e.g. `HasVirtualBase` is rightly no longer considered loadable) - Don't import copy or move constructors (noticed this because references are now imported correctly, so copy and move constructors suddenly started showing up in the SIL test) - Don't try to define an implicitly-deleted default constructor (this previously broke loadable-types-silgen.swift)

view details

Martin Boehme

commit sha beaaa742c3e774b6739de26bb1a3f0c8761512a5

Don't put an `sret` attribute on the `this` argument.

view details

Martin Boehme

commit sha 8416ccfa06d05da67af70a8ed57a2f120ea251b2

Rename constructors-ir.swift to constructors-irgen.swift.

view details

Martin Boehme

commit sha 8f6042aa0870a527505262c7dbe89ec7ffe20e12

Add additional IR tests for a class without a virtual base class.

view details

Martin Boehme

commit sha c9405fb7fc338f59db4386488245a3ce82227e00

Add Windows-name-mangled version of symbol to SIL test.

view details

Martin Boehme

commit sha cb4ddda6e2292c584cb83905f3f9df17a4e017f1

Avoid crashing if lldb imports C++ structs without enabling C++ interop.

view details

push time in 21 hours

push eventapple/swift

Mike Ash

commit sha 782fa272064151ba17cde6f4d75011871d78c1ee

[Runtime] Move ElementCapacity into the Elements allocation. This shrinks ConcurrentReadableHashMap a bit, which will be needed for adapting it for metadata caches.

view details

Mike Ash

commit sha 7f2185d30e6408ede1981307677945f55b155d22

Merge pull request #34464 from mikeash/concurrentreadablehashmap-move-elementcapacity [Runtime] Move ElementCapacity into the Elements allocation.

view details

push time in a day

PR merged apple/swift

[Runtime] Move ElementCapacity into the Elements allocation.

This shrinks ConcurrentReadableHashMap a bit, which will be needed for adapting it for metadata caches.

+41 -22

4 comments

2 changed files

mikeash

pr closed time in a day

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Dynamic Casting: Properly unwrap existential metatype sources

 CastsTests.test("Async function types") {   expectFalse(asyncFnType is (() -> Void).Type) } +CastsTests.test("AnyObject.Type -> AnyObject") {+  class C {}+  let a = C.self+  let b = a as? AnyObject.Type+  expectNotNil(b)+  let c = b as? AnyObject+  expectNotNil(c)+  expectTrue(c! === a)+  let d = runtimeCast(b, to: AnyObject.self)+  expectNotNil(d)+  expectTrue(d! === a)+  let e = c as? C.Type+  expectNotNil(e)+  expectTrue(e! === a)+  let f = runtimeCast(d, to: C.Type.self)+  expectNotNil(f)+  expectTrue(f! === a)+  blackhole(c)+  blackhole(d)+  blackhole(e)+  blackhole(f)

Since these values are all checked, do these blackhole calls serve a purpose?

tbkka

comment created time in a day

pull request commentapple/swift

[Runtime] Move ElementCapacity into the Elements allocation.

All tests passed except for symbol-visibility-linux.sh. Just pushed a fix for that.

mikeash

comment created time in a day

pull request commentapple/swift

[Runtime] Move ElementCapacity into the Elements allocation.

@swift-ci please smoke test

mikeash

comment created time in a day

push eventmikeash/swift

Mike Ash

commit sha 782fa272064151ba17cde6f4d75011871d78c1ee

[Runtime] Move ElementCapacity into the Elements allocation. This shrinks ConcurrentReadableHashMap a bit, which will be needed for adapting it for metadata caches.

view details

push time in a day

pull request commentapple/swift

[Runtime] Move ElementCapacity into the Elements allocation.

@swift-ci please test

mikeash

comment created time in 2 days

PR opened apple/swift

Reviewers
[Runtime] Move ElementCapacity into the Elements allocation.

This shrinks ConcurrentReadableHashMap a bit, which will be needed for adapting it for metadata caches.

+39 -22

0 comment

1 changed file

pr created time in 2 days

create barnchmikeash/swift

branch : concurrentreadablehashmap-move-elementcapacity

created branch time in 2 days

pull request commentapple/swift

[Runtime] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small.

@swift-ci please benchmark

mikeash

comment created time in 2 days

PR opened apple/swift

Reviewers
[Runtime] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small.

We use the lower two bits of the indices value to indicate the index size and inline-ness. When stored inline, we can pack 7 or 15 (on 32-bit and 64-bit respectively) values inline, meaning we don't need a heap allocation until we exceed that size, and avoiding the cost of an additional read in those cases.

+141 -70

0 comment

1 changed file

pr created time in 2 days

push eventmikeash/swift

Mike Ash

commit sha 9f53d4a52e2055ddb89b0823fc79e37e3c4ec9b7

[Runtime] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small.

view details

push time in 2 days

push eventmikeash/swift

Mike Ash

commit sha ce86c35a00a1e71acea5ddcef63fb8ba98122ba9

[Runtime] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small.

view details

push time in 2 days

create barnchmikeash/swift

branch : concurrentreadablehashmap-inline-indices

created branch time in 2 days

PullRequestReviewEvent

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

Playing with some perf improvements to the hashmap code. I'll make them a separate PR if they pan out.

mikeash

comment created time in 6 days

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

@swift-ci please benchmark

mikeash

comment created time in 6 days

push eventmikeash/swift

Mike Ash

commit sha e26ec4196f5fc55f55823d4b8dc785fbe457cf70

Switch ConcurrentReadableHashMap::IndexStorage to hold its own pointer in preparation for inline storage.

view details

Mike Ash

commit sha 82d653213fa6d03fb52671588bed41aeb5d7dd32

Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small.

view details

Mike Ash

commit sha 343a15d72cd2768e6a034d49e244ed5683eb032a

When ConcurrentReadableHashMap::Snapshot only has one element, skip hashing and just check that one element.

view details

push time in 6 days

push eventapple/swift

Mike Ash

commit sha 17e31d89d2491708aaaab2fd535c229327c979c1

[Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp. The conditional use of objc_addLoadImageFunc was accidentally removed in b5759c9fd93ea9d09613c018c48217e7e03f30bd. Put it back. rdar://problem/70452221

view details

Mike Ash

commit sha bf7fa56b78d043b5a89c287182210074e139d7cd

Merge pull request #34354 from mikeash/restore-objc_addLoadImageFunc [Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp.

view details

push time in 8 days

PR merged apple/swift

Reviewers
[Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp.

The conditional use of objc_addLoadImageFunc was accidentally removed in b5759c9fd93ea9d09613c018c48217e7e03f30bd. Put it back.

rdar://problem/70452221

+5 -1

1 comment

1 changed file

mikeash

pr closed time in 8 days

push eventapple/swift

Mike Ash

commit sha b1633fdc361c847d0d22fa2ca1a674bad480200e

[Test] Remove `as AnyObject` cast from OS_objects.swift. This workaround is no longer needed. rdar://problem/27526994

view details

Mike Ash

commit sha 1be717181723bf93f5e0ac6ccc0948494417bec1

Merge pull request #34350 from mikeash/remove-os-object-test-workaround [Test] Remove `as AnyObject` cast from OS_objects.swift.

view details

push time in 8 days

PR merged apple/swift

Reviewers
[Test] Remove `as AnyObject` cast from OS_objects.swift.

This workaround is no longer needed.

rdar://problem/27526994

+2 -3

1 comment

1 changed file

mikeash

pr closed time in 8 days

pull request commentapple/swift

[Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp.

@swift-ci please test

mikeash

comment created time in 10 days

PR opened apple/swift

Reviewers
[Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp.

The conditional use of objc_addLoadImageFunc was accidentally removed in b5759c9fd93ea9d09613c018c48217e7e03f30bd. Put it back.

rdar://problem/70452221

+5 -1

0 comment

1 changed file

pr created time in 10 days

create barnchmikeash/swift

branch : restore-objc_addLoadImageFunc

created branch time in 10 days

pull request commentapple/swift

[Test] Remove `as AnyObject` cast from OS_objects.swift.

@swift-ci please test

mikeash

comment created time in 10 days

PR opened apple/swift

Reviewers
[Test] Remove `as AnyObject` cast from OS_objects.swift.

This workaround is no longer needed.

rdar://problem/27526994

+2 -3

0 comment

1 changed file

pr created time in 10 days

create barnchmikeash/swift

branch : remove-os-object-test-workaround

created branch time in 10 days

push eventmikeash/swift

Mike Ash

commit sha b1633fdc361c847d0d22fa2ca1a674bad480200e

[Test] Remove `as AnyObject` cast from OS_objects.swift. This workaround is no longer needed. rdar://problem/27526994

view details

push time in 10 days

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

Ah, I didn't catch that it could be an interior pointer! I'm OK with major surgery to improve the cases that can benefit from it, but I will keep in mind that it won't be easy. I'll keep my eye out for better approaches, too.

In the meantime, I need to figure out these benchmark regressions before I land this one....

mikeash

comment created time in 13 days

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

The entries store a pointer:

...
  /// Valid if TrackingInfo.getState() >= PrivateMetadataState::Abstract.
  ValueType Value;

I think the entry can be created before the size is known, so it has to be separate.

mikeash

comment created time in 14 days

Pull request review commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

 struct ConcurrencyControl {   ConcurrencyControl() = default; }; -template <class EntryType, uint16_t Tag, bool ProvideDestructor = true>+template <class EntryType, uint16_t Tag>

Ah, that'll do it too.

mikeash

comment created time in 14 days

PullRequestReviewEvent

Pull request review commentapple/swift

Test the just-built libraries when building unittests on Darwin

+#!/usr/bin/env python++# On Darwin, dynamic libraries have an install name.  At link time, the+# linker can work with a dylib anywhere in the filesystem, but it will+# write the dylib's install name into the resulting image, and at load+# time that dylib will normally be expected to be found at exactly that+# path.  However, if the install name in an image begins with `@rpath`,+# it will instead be searched for in the image's runtime search path+# list.  That list may contain absolute paths, but it may also contain+# paths beginning with `@executable_path` or `@loader_path`, meaning the+# path containing the running executable or the image being loaded,+# respectively.+#+# Many of Swift's dylibs are meant to be installed on the system, which+# means they have install names like this:+#   /usr/lib/swift/libswiftFoo.dylib+# To support back-deployment, they also provide magic override symbols+# ($ld$install_name) for all the OS versions preceding the addition of+# of the library.  When the linker finds a dylib with a matching override+# for the OS deployment target, it ignores the normal install name and+# uses the override path in the linked image's load command.  Swift's+# libraries use override paths that begin with `@rpath`, and Swift+# builds images with a runtime search path list that starts with+# /usr/lib/swift but then falls back on a path relative to the image;+# thus, apps will use the system libraries if available but will+# otherwise use fallback libraries.+#+# When we're working on Swift, we usually want to test the libraries+# we just built rather than the system libraries.  There are two ways+# to achieve that.  The first is to override dyld's runtime search path+# with DYLD_LIBRARY_PATH; this will take precedence over even an+# absolute install name.  The second is to make sure the dylibs are+# loaded via an @rpath install name and then link the program with an+# rpath that will use the just-built libraries.  Unfortunately, the+# toolchain will ordinarily use an absolute install name instead of+# an @rpath if the deployment target is old enough, subverting testing.+#+# This script looks for dependent dylibs with an absolute path in+# /usr/lib/swift and changes them to use @rpath.++import argparse+import re+import subprocess+import sys+++def main(arguments):+    parser = argparse.ArgumentParser(+        description='Change absolute install names to use @rpath')+    parser.add_argument('bin', help='the binary')++    args = parser.parse_args(arguments)+    rpathize(args.bin)+++def rpathize(filename):+    dylibsOutput = subprocess.check_output(+        ['xcrun', 'dyldinfo', '-dylibs', filename])++    # The output from dyldinfo -dylibs is a line of header followed by one+    # install name per line, indented with spaces.+    dylib_regex = re.compile(+        r"^\s*(?P<path>/usr/lib/swift/(?P<filename>.*\.dylib))\s*$")

OK, that ought to be sufficiently robust.

rjmccall

comment created time in 14 days

PullRequestReviewEvent

Pull request review commentapple/swift

Test the just-built libraries when building unittests on Darwin

+#!/usr/bin/env python++# On Darwin, dynamic libraries have an install name.  At link time, the+# linker can work with a dylib anywhere in the filesystem, but it will+# write the dylib's install name into the resulting image, and at load+# time that dylib will normally be expected to be found at exactly that+# path.  However, if the install name in an image begins with `@rpath`,+# it will instead be searched for in the image's runtime search path+# list.  That list may contain absolute paths, but it may also contain+# paths beginning with `@executable_path` or `@loader_path`, meaning the+# path containing the running executable or the image being loaded,+# respectively.+#+# Many of Swift's dylibs are meant to be installed on the system, which+# means they have install names like this:+#   /usr/lib/swift/libswiftFoo.dylib+# To support back-deployment, they also provide magic override symbols+# ($ld$install_name) for all the OS versions preceding the addition of+# of the library.  When the linker finds a dylib with a matching override+# for the OS deployment target, it ignores the normal install name and+# uses the override path in the linked image's load command.  Swift's+# libraries use override paths that begin with `@rpath`, and Swift+# builds images with a runtime search path list that starts with+# /usr/lib/swift but then falls back on a path relative to the image;+# thus, apps will use the system libraries if available but will+# otherwise use fallback libraries.+#+# When we're working on Swift, we usually want to test the libraries+# we just built rather than the system libraries.  There are two ways+# to achieve that.  The first is to override dyld's runtime search path+# with DYLD_LIBRARY_PATH; this will take precedence over even an+# absolute install name.  The second is to make sure the dylibs are+# loaded via an @rpath install name and then link the program with an+# rpath that will use the just-built libraries.  Unfortunately, the+# toolchain will ordinarily use an absolute install name instead of+# an @rpath if the deployment target is old enough, subverting testing.+#+# This script looks for dependent dylibs with an absolute path in+# /usr/lib/swift and changes them to use @rpath.++import argparse+import re+import subprocess+import sys+++def main(arguments):+    parser = argparse.ArgumentParser(+        description='Change absolute install names to use @rpath')+    parser.add_argument('bin', help='the binary')++    args = parser.parse_args(arguments)+    rpathize(args.bin)+++def rpathize(filename):+    dylibsOutput = subprocess.check_output(+        ['xcrun', 'dyldinfo', '-dylibs', filename])++    # The output from dyldinfo -dylibs is a line of header followed by one+    # install name per line, indented with spaces.+    dylib_regex = re.compile(+        r"^\s*(?P<path>/usr/lib/swift/(?P<filename>.*\.dylib))\s*$")++    # Build a command to invoke install_name_tool.+    command = ['install_name_tool']+    for line in dylibsOutput.splitlines():+        match = dylib_regex.match(line)+        if match:+            command.append('-change')+            command.append(match.group('path'))+            command.append('@rpath/' + match.group('filename'))+            continue++    # Don't run the command if we didn't find any dylibs to change:+    # it's invalid to invoke install_name_tool without any operations.+    if len(command) == 1:

Are there legitimate cases where this would happen? It would be nice to check for whatever those cases are and fail otherwise, so some change in output from the tool doesn't make us go back to silently testing the OS runtime.

rjmccall

comment created time in 14 days

PullRequestReviewEvent

Pull request review commentapple/swift

Test the just-built libraries when building unittests on Darwin

+#!/usr/bin/env python++# On Darwin, dynamic libraries have an install name.  At link time, the+# linker can work with a dylib anywhere in the filesystem, but it will+# write the dylib's install name into the resulting image, and at load+# time that dylib will normally be expected to be found at exactly that+# path.  However, if the install name in an image begins with `@rpath`,+# it will instead be searched for in the image's runtime search path+# list.  That list may contain absolute paths, but it may also contain+# paths beginning with `@executable_path` or `@loader_path`, meaning the+# path containing the running executable or the image being loaded,+# respectively.+#+# Many of Swift's dylibs are meant to be installed on the system, which+# means they have install names like this:+#   /usr/lib/swift/libswiftFoo.dylib+# To support back-deployment, they also provide magic override symbols+# ($ld$install_name) for all the OS versions preceding the addition of+# of the library.  When the linker finds a dylib with a matching override+# for the OS deployment target, it ignores the normal install name and+# uses the override path in the linked image's load command.  Swift's+# libraries use override paths that begin with `@rpath`, and Swift+# builds images with a runtime search path list that starts with+# /usr/lib/swift but then falls back on a path relative to the image;+# thus, apps will use the system libraries if available but will+# otherwise use fallback libraries.+#+# When we're working on Swift, we usually want to test the libraries+# we just built rather than the system libraries.  There are two ways+# to achieve that.  The first is to override dyld's runtime search path+# with DYLD_LIBRARY_PATH; this will take precedence over even an+# absolute install name.  The second is to make sure the dylibs are+# loaded via an @rpath install name and then link the program with an+# rpath that will use the just-built libraries.  Unfortunately, the+# toolchain will ordinarily use an absolute install name instead of+# an @rpath if the deployment target is old enough, subverting testing.+#+# This script looks for dependent dylibs with an absolute path in+# /usr/lib/swift and changes them to use @rpath.++import argparse+import re+import subprocess+import sys+++def main(arguments):+    parser = argparse.ArgumentParser(+        description='Change absolute install names to use @rpath')+    parser.add_argument('bin', help='the binary')++    args = parser.parse_args(arguments)+    rpathize(args.bin)+++def rpathize(filename):+    dylibsOutput = subprocess.check_output(+        ['xcrun', 'dyldinfo', '-dylibs', filename])++    # The output from dyldinfo -dylibs is a line of header followed by one+    # install name per line, indented with spaces.+    dylib_regex = re.compile(+        r"^\s*(?P<path>/usr/lib/swift/(?P<filename>.*\.dylib))\s*$")

The output hints at a first column of attributes that just happens to be empty:

attributes     dependent dylibs
                /usr/lib/libicucore.A.dylib
...

I wonder if that can ever be non-empty. It would cause this to silently fail, which would be unfortunate.

otool -L or llvm-objdump -macho -dylibs-used avoids that, although it prints some version number info we don't care about, like:

	/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 0.0.0)

Not sure if that's actually any better.

rjmccall

comment created time in 14 days

PullRequestReviewEvent

Pull request review commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

 struct ConcurrencyControl {   ConcurrencyControl() = default; }; -template <class EntryType, uint16_t Tag, bool ProvideDestructor = true>+template <class EntryType, uint16_t Tag>

I couldn't find any. ConcurrentMap doesn't support removal. It does support destroying the entire tree, but all uses of it just create it and let it live forever. I assume this was left over from a much earlier era when it was thought that these caches might not be permanent, or metadata might not be immortal.

mikeash

comment created time in 14 days

PullRequestReviewEvent

Pull request review commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

 class TupleCacheEntry     return 0; // No single meaningful value   } -  int compareWithKey(const Key &key) const {-    // Order by the cheaper comparisons first:+  friend llvm::hash_code hash_value(const TupleCacheEntry &value) {+    llvm::SmallVector<const Metadata *, 16> elements;+    elements.reserve(value.Data.NumElements);+    for (size_t i = 0, e = value.Data.NumElements; i != e; ++i) {+      elements.push_back(value.Data.getElement(i).Type);+    }++    Key key{value.Data.NumElements, elements.data(), value.Data.Labels};+    return hash_value(key);

I couldn't find a nice way to do it, but I didn't know we had TransformRange. That looks nice and simple, I'll do that.

Note that entry hashes are only used when resizing the table, so it's not a performance impact for lookups. But it's still definitely worth doing better.

mikeash

comment created time in 14 days

PullRequestReviewEvent

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

So the actual entry in the hashtable now is an EntryType*, right? Or is it indirected an extra step for some reason?

That's right. The wrapper forwards key matching operations, but it's ultimately just a pointer, so there's just one level of indirection. As I mention in the PR description, I'd like to even get rid of that, but it's a bigger job.

mikeash

comment created time in 14 days

pull request commentapple/swift

[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

@swift-ci please benchmark

mikeash

comment created time in 15 days

PR opened apple/swift

Reviewers
[Runtime] Switch MetadataCache to ConcurrentReadableHashMap.

Use StableAddressConcurrentReadableHashMap for now. MetadataCacheEntry's methods for awaiting a particular state assume a stable address, where it will repeatedly examine this in a loop while waiting on a condition variable, so we give it a stable address to accommodate that. This code can be changed to perform the necessary table lookup each time through the loop instead, and thus allow us to use a plain ConcurrentReadableHashMap and avoid the extra indirection, and I'll take care of that in a followup.

rdar://problem/70220660

+90 -81

0 comment

3 changed files

pr created time in 15 days

PullRequestReviewEvent

push eventapple/swift

Mike Ash

commit sha 630aff7b19b80f29445b645424e20fd1bb6bd551

[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap. This gives us faster lookups and a small advantage in memory usage. Most of these maps need stable addresses for their entries, so we add a level of indirection to ConcurrentReadableHashMap for these cases to accommodate that. This costs some extra memory, but it's still a net win. A new StableAddressConcurrentReadableHashMap type handles this indirection and adds a convenience getOrInsert to take advantage of it. ConcurrentReadableHashMap is tweaked to avoid any global constructors or destructors when using it as a global variable. ForeignWitnessTables does not need stable addresses and it now uses ConcurrentReadableHashMap directly. rdar://problem/70056398

view details

Mike Ash

commit sha daca3d9cf06d84f0930f7632ebd2c8089e5d1396

Merge pull request #34225 from mikeash/simpleglobalcache-concurrentreadablehashmap [Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

view details

push time in 16 days

PR merged apple/swift

Reviewers
[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

This gives us faster lookups and a small advantage in memory usage. Most of these maps need stable addresses for their entries, so we add a level of indirection to ConcurrentReadableHashMap for these cases to accommodate that. This costs some extra memory, but it's still a net win.

A new StableAddressConcurrentReadableHashMap type handles this indirection and adds a convenience getOrInsert to take advantage of it.

ConcurrentReadableHashMap is tweaked to avoid any global constructors or destructors when using it as a global variable.

ForeignWitnessTables does not need stable addresses and it now uses ConcurrentReadableHashMap directly.

rdar://problem/70056398

+217 -78

5 comments

5 changed files

mikeash

pr closed time in 16 days

pull request commentapple/swift

[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

@rjmccall @aschwaighofer Could one of you check this over and make sure I didn't do anything too obviously dumb?

mikeash

comment created time in 16 days

pull request commentapple/swift

[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

@swift-ci please test

mikeash

comment created time in 17 days

create barnchmikeash/swift

branch : metadatacache-concurrentreadablehashmap

created branch time in 17 days

pull request commentapple/swift

[Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

Yeah, I just realized that the hard way. :(

mikeash

comment created time in 21 days

push eventmikeash/swift

Pavel Yaskevich

commit sha e6b140e32bc2c3af07804ce0755723f5a619863c

[Runtime] NFC: Fix `swift_runtime_unreachable` to `swift_unreachable`

view details

Mishal Shah

commit sha a373e8573400d2613625c09c364fb979cbab8a06

Merge pull request #34237 from xedin/fix-rename-of-unreachable [Runtime] NFC: Fix `swift_runtime_unreachable` to `swift_unreachable`

view details

Mike Ash

commit sha 630aff7b19b80f29445b645424e20fd1bb6bd551

[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap. This gives us faster lookups and a small advantage in memory usage. Most of these maps need stable addresses for their entries, so we add a level of indirection to ConcurrentReadableHashMap for these cases to accommodate that. This costs some extra memory, but it's still a net win. A new StableAddressConcurrentReadableHashMap type handles this indirection and adds a convenience getOrInsert to take advantage of it. ConcurrentReadableHashMap is tweaked to avoid any global constructors or destructors when using it as a global variable. ForeignWitnessTables does not need stable addresses and it now uses ConcurrentReadableHashMap directly. rdar://problem/70056398

view details

push time in 21 days

push eventmikeash/swift

Mike Ash

commit sha ece0399d601eec1069131f465bdbe7e16f4c6a50

[Runtime] Have ConcurrentReadableHashMap use 1-byte or 2-byte indices when possible.

view details

Cassie Jones

commit sha e01893cb56f989b20ba4309286450105211f031e

[build-script] Add a flag for sccache This adds a flag to enable sccache in order to simplify the build-script invocation, particularly for new contributors.

view details

Cassie Jones

commit sha 6d92486c9a6ddc8b71f7c842d546ae3599be5c30

[build-script] Add SWIFT_ prefix to USE_SCCACHE env var

view details

Nate Chandler

commit sha 4cfadfae00f31fc66581ad270176e4916682bf51

[NFC] Documented IRGenFunction::IndirectReturn.

view details

Nate Chandler

commit sha 607772aaa21ce58db04236cb817b5958c72b2123

[Runtime] Stubbed entry points for task de/alloc.

view details

Cassie Jones

commit sha 7ef9b3287ab097ce2bdd1ab70f9ed9df20d39ff1

[build-script] Fix CMake sccache test

view details

Cassie Jones

commit sha b5247d2c8f9c4133ba165370d92370600cf67ece

Fix formatting issue

view details

Nate Chandler

commit sha 59bb1fc23592bcc4eb18bca32dcbff9de4b7e751

[Concurrency] Pass "async" into SILFunctionTypes. This reverts commit 3a48396110d2639d7b90970bc0369a559adbc0c1.

view details

Doug Gregor

commit sha e36011def493dceec79381f2e4a051f1f1e610fe

[Type checker] Delay the diagnosis of missing witnesses further. The handling of "global" missing witnesses would diagnose a missing witness (showing "almost" matches) and then, later, provide the Fix-It to add the declaration if the user wants it. Delay the diagnostic part until later, when we add the missing witness. While here, correct an existing issue with memory corruption that occurs because we would diagnose some of these witnesses, then clear a "global" witness list, while still iterating through parts of that list.

view details

Doug Gregor

commit sha fe4a8bb9f926684d2621fba13cc326580380bcbc

[Clang importer] Allow both sync and async imports with the same name. The Clang importer was filtering out cases where the same declaration is imported twice under the same name, which can now happen when one is synchronous and one is asynchronous. This happens when, e.g., an Objective-C class provides both a completion-hander-based asynchronous version and a synchronous version, and the Swift names line up after the completion-handler parameter is dropped. Stop filtering these out. Overload resolution is capable of handling synchronous/asynchronous overloading based on context.

view details

Doug Gregor

commit sha 50f870566a1a35b4073adb1bce078451790b74a5

Handle conformance with multiple protocol requirements with the same selector. When concurrency is enabled, the same Objective-C method on a protocol can be imported as two different protocol requirements, both of which have the same selector. When performing conformance checking, only treat a given @objc protocol requirement as "unsatisfied" by a conformance if none of the requirements with the same Objective-C selector (+ instance/class designation) are satisfied.

view details

Doug Gregor

commit sha 591e6e89e259818a8dd56bbba41057e776d92c8a

[Concurrency] Only infer @asyncHandler for witnesses within actor classes. Actor classes are by definition new code, so only perform inference of @asyncHandler from a protocol requirement to witnesses when those witnesses are within an actor class. This is partly because @asyncHandler might not have reasonable semantics outside of actor classes anywhere (where would you execute the detached task?), and partly because it is a source-compatibility problem due to the combination of... 1) Inferring @asyncHandler on imported Objective-C protocol methods for existing protocols, 2) Inferring @asyncHandler from those protocol methods to an existing method in a class that conforms to that protocol, and 3) Using an API that is now overloaded for both synchronous and asynchronous callers will end up preferring the asynchronous version, then fail due to a missing "await". The individual steps here are all reasonable, but the result is a source break, so back off on @asyncHandler inference for witnesses outside of actor classes. New code gets the more-asynchronous behavior for free.

view details

Doug Gregor

commit sha bb066b6fa68f06885c84838be7f7e264d70bc0e6

[Concurrency] Make actor-isolated protocol witnesses an error. With actor isolation checking for protocol witnesses moved out of the witness-matching phase, move the corresponding diagnostics from notes (that would have been on the "type does not conform" error) to freestanding errors.

view details

Simon Evans

commit sha 960d0e30ee2b70ba3bb7ec076c16045afab01589

Linux: Fix -static-executable and remove swiftImageInspectionShared - Remove references to swiftImageInspectionShared on Linux and dont have split libraries between static/non-static linked executables. - -static-executable now links correctly Linux. Note: swift::lookupSymbol() will not work on statically linked executables but this can be worked around by using the https://github.com/swift-server/swift-backtrace package.

view details

Vincent Esche

commit sha 6ab35727cf5baed7d7bab1bad7b1201f057c5d59

Fixed docs link to Rust's demand-driven compilation guide

view details

Cassie Jones

commit sha 8ffaf79ec2e106a58dff2402a06210bf9ca97357

[build] Support installing swift-driver without swiftpm The install-swift-driver phase knows how to build swift-driver using CMake. Allowing only install-swift-driver without plain swift-driver allows installing it without requiring swiftpm.

view details

Michael Gottesman

commit sha e7761cf997897aaa38af0d0969ca9acd7e504fbf

[DebuggingTheCompiler] Document a few flags for dumping llvm-ir. I needed to use these and realized they were not documented here. I had them in my brain, but others may not, so seemed good to do.

view details

Meghana Gupta

commit sha f4bbafb392d838746f4de60d98aa655efff04c8e

Revert "[PassManager] Update PassManager's function worklist for newly added SILFunctions"

view details

Argyrios Kyrtzidis

commit sha 73727051fa61fe48b12bfc72233cdf28d804f58f

[AST] Fix linker errors with the parser-only build

view details

Mishal Shah

commit sha 161899d49015a68f0087a2a94ec9fb3a732212e8

Merge pull request #34133 from porglezomp-misc/twist-it-bop-it-sccache-it [build-script] Add a flag for sccache

view details

push time in 21 days

push eventapple/swift

Mike Ash

commit sha ece0399d601eec1069131f465bdbe7e16f4c6a50

[Runtime] Have ConcurrentReadableHashMap use 1-byte or 2-byte indices when possible.

view details

Mike Ash

commit sha d369ce1bb542646ea5934370efb129eb614eacfe

Merge pull request #34063 from mikeash/concurrenthashmap-indices-shrink [Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

view details

push time in 21 days

PR merged apple/swift

Reviewers
[Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

When ConcurrentReadableHashMap contains few items, have it use smaller indices to make that array more compact.

This will have a small but useful impact on the protocol conformance cache, where ConcurrentReadableHashMap is currently used. Most apps will have fewer than 65,536*0.75 entries in that cache, so we'll cut the index storage in half.

It will be more useful when ConcurrentReadableHashMap starts being used for other maps in the runtime, as a lot of them never grow very large.

+97 -38

3 comments

1 changed file

mikeash

pr closed time in 21 days

Pull request review commentapple/swift

Add check for Xcode version compatibility

 def print_xcodebuild_versions(file=sys.stdout):     print(fmt.format(version=version, sdks=sdks), file=file)     file.flush() +def validate_xcode_compatibility():+    if sys.platform != 'darwin':+        return++    if os.getenv("SKIP_XCODE_VERSION_CHECK"):+        print("note: skipping Xcode version check")+        return++    version = shell.capture(+        ['xcodebuild', '-version'], dry_run=False, echo=False).strip()+    if not version.endswith(_SUPPORTED_XCODE_BUILDS):+        raise SystemExit(+            "error: using unsupported Xcode version:\n\n{}\n\nInstall one of: {}".format(

Would be good to add "or set SKIP_XCODE_VERSION_CHECK to skip this check at your own risk" so the workaround is immediately visible.

keith

comment created time in 22 days

PullRequestReviewEvent

pull request commentapple/swift

[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

@swift-ci please benchmark

mikeash

comment created time in 22 days

PR opened apple/swift

Reviewers
[Runtime] Change SimpleGlobalCache to use ConcurrentReadableHashMap instead of ConcurrentMap.

This gives us faster lookups and a small advantage in memory usage. Most of these maps need stable addresses for their entries, so we add a level of indirection to ConcurrentReadableHashMap for these cases to accommodate that. This costs some extra memory, but it's still a net win.

A new StableAddressConcurrentReadableHashMap type handles this indirection and adds a convenience getOrInsert to take advantage of it.

ConcurrentReadableHashMap is tweaked to avoid any global constructors or destructors when using it as a global variable.

ForeignWitnessTables does not need stable addresses and it now uses ConcurrentReadableHashMap directly.

rdar://problem/70056398

+217 -78

0 comment

5 changed files

pr created time in 22 days

create barnchmikeash/swift

branch : simpleglobalcache-concurrentreadablehashmap

created branch time in 22 days

pull request commentapple/swift

[build] properly install compiler-rt from Xcode toolchain

There shouldn't be any trouble with a version mismatch. We need a compatible library but not necessarily one that precisely matches the Xcode you're using.

edymtt

comment created time in 23 days

pull request commentapple/swift

[Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

@swift-ci please test os x platform

mikeash

comment created time in a month

pull request commentapple/swift

[Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

@swift-ci please test

mikeash

comment created time in a month

push eventmikeash/swift

Mike Ash

commit sha ece0399d601eec1069131f465bdbe7e16f4c6a50

[Runtime] Have ConcurrentReadableHashMap use 1-byte or 2-byte indices when possible.

view details

push time in a month

PR opened apple/swift

Reviewers
[Runtime] Use 1-byte or 2-byte indices in ConcurrentReadableHashMap when possible.

When ConcurrentReadableHashMap contains few items, have it use smaller indices to make that array more compact.

This will have a small but useful impact on the protocol conformance cache, where ConcurrentReadableHashMap is currently used. Most apps will have fewer than 65,536*0.75 entries in that cache, so we'll cut the index storage in half.

It will be more useful when ConcurrentReadableHashMap starts being used for other maps in the runtime, as a lot of them never grow very large.

+99 -37

0 comment

1 changed file

pr created time in a month

push eventmikeash/swift

Mike Ash

commit sha fc9348c2822edf8ea57763eef9b0668bc1938e63

Have ConcurrentReadableHashMap use 1-byte or 2-byte indices when possible.

view details

push time in a month

push eventmikeash/swift

Mike Ash

commit sha f1810ada7235f5a1c1a6cab16ca22cf5d9d67ad3

Have ConcurrentReadableHashMap use 1-byte or 2-byte indices when possible.

view details

push time in a month

PullRequestReviewEvent

create barnchmikeash/swift

branch : concurrenthashmap-indices-shrink

created branch time in a month

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Add a SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC flag to allow/disallow uses of Darwin libmalloc APIs (malloc_default_zone, malloc_zone_malloc, etc.)

 template <class ElemTy> struct ConcurrentReadableHashMap {   /// Otherwise, just return the passed-in size, which is always valid even if   /// not necessarily optimal.   size_t goodSize(size_t size) {-#if defined(__APPLE__) && defined(__MACH__)+#if defined(__APPLE__) && defined(__MACH__) && \+        defined(SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC)

You'll want this to just be SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC (no defined() around it) to handle the case where it's 0.

kubamracek

comment created time in 2 months

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Add a SWIFT_STDLIB_OS_VERSIONING flag to avoid querying OS version at runtime, use it in the freestanding build

 public func _stdlib_isOSVersionAtLeast(   _ minor: Builtin.Word,   _ patch: Builtin.Word ) -> Builtin.Int1 {-#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)+#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_RUNTIME_NO_OS_VERSIONING

Great, thank you!

kubamracek

comment created time in 2 months

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentapple/swift

Add a SWIFT_STDLIB_OS_VERSIONING flag to avoid querying OS version at runtime, use it in the freestanding build

 public func _stdlib_isOSVersionAtLeast(   _ minor: Builtin.Word,   _ patch: Builtin.Word ) -> Builtin.Int1 {-#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)+#if (os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) && !SWIFT_RUNTIME_NO_OS_VERSIONING

These double negatives make my brain go all squishy. Can you change it to be a positive instead (like SWIFT_RUNTIME_OS_VERSIONING) to avoid that?

kubamracek

comment created time in 2 months

PullRequestReviewEvent
more