Skip to content

Instantly share code, notes, and snippets.

View rjmccall's full-sized avatar

John McCall rjmccall

View GitHub Profile
FAIL: Swift(macosx-x86_64) :: StringProcessing/Parse/regex.swift (6323 of 8220)
******************** TEST 'Swift(macosx-x86_64) :: StringProcessing/Parse/regex.swift' FAILED ********************
Script:
--
: 'RUN: at line 1'; /Users/rjmccall/dev/swift/build/Ninja-DebugAssert+asan/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.9 -module-cache-path /Users/rjmccall/dev/swift/build/Ninja-DebugAssert+asan/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk' -swift-version 4 -define-availability 'SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999' -define-availability 'SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2' -define-availability 'SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0' -define-availability 'SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4' -define-availability 'SwiftStdlib 5.3:macOS
@rjmccall
rjmccall / actor-custom-executors.md
Created January 7, 2021 09:32
Draft pitch for Swift custom actor executors

The actors pitch lays out a simple design for how code is executed on an actor. I will summarize this briefly, and along the way I'll point out some perceived problems.

Overview

Conceptually, an actor has an exclusive execution service ("executor"). When a task wants to start running on an actor, it "parks" itself, becoming an opaque chunk of work that can be run by an executor (a "partial task"). It then submits itself to the actor's executor to run.

By default, actors use a standard executor implementation provided by the Swift runtime using a certain amount of inline storage in the actor object. The standard implementation is less like a serial queue and more like an "asynchronous lock". If there's no contention on an actor, a task can switch to it by simply continuing execution on the current thread without any interruption. The standard-implementation actors are able to freely shift between threads: running for awhile

@rjmccall
rjmccall / gist:788565b007db74c6eba3063b63b19d64
Created October 22, 2020 04:15
Things to improve in the Swift ABI
1. The ABI for allocating initializers is messed up. We preserve the metadata in swiftself, forcing a lot of re-use. Ideally the metadata would be passed in (maybe in the swiftself register?) and we'd return the object in swiftself.
2. We should have a swift_allocObject that knows it's been given a class metadata and pulls the dimensions out of it.
[expr.unary.op] permits forming a member pointer that selects a virtual function. A call to such a member pointer performs a virtual function call ([expr.call]p3), and equality comparisons involving such a member pointer have unspecified results except that they compare unequal to the null member pointer ([expr.eq]p4).
The predominant implementation strategy for non-virtual member function pointers is to simply store the address of the member function. There are two implementation strategies for virtual member function pointers:
1. Store the address (as if forming a non-virtual member pointer) of an implicit, inline, non-virtual member function (a "thunk") which performs the requested virtual call.
2. Store the offset of the target virtual function within the class's virtual function table, in some way that can be reliably distinguished from a pointer to a non-virtual member function.
Both of these strategies are in use today. Unfortunately, it is unclear whether the use of thunks is strictly compliant
// A program to find two fixed-precision numbers which, when
// multiplied, yield the maximum representable value of the type
// plus a non-zero unrepresentable epsilon.
//
// Author: John McCall <rjmccall@gmail.com>
#include <stdio.h>
#include <err.h>
#include <iostream>
@rjmccall
rjmccall / gist:385ca49b3c5dc9ec01ba3af05fcd6e67
Created August 24, 2018 07:14
Preliminary code-size report #1 on coroutines
https://github.com/apple/swift/pull/18840
x86-64 macOS Ninja-ReleaseAssert (i.e. build-script -R)
BASELINE: commit 872463d6c63bc398cea5ec4f1b462b15735560eb
lib/swift/macosx:
total 25568
136 libswiftAVFoundation.dylib
68 libswiftAccelerate.dylib