profile
viewpoint

factor/factor 972

Factor programming language

jckarter/clay 380

The Clay programming language

jckarter/hello-gl 109

"Hello World" in OpenGL 2.0

jckarter/selfaware 42

Self-aware struct-like types in C++11

jckarter/ch4-flag 21

Demo program for Modern OpenGL intro ch4

jckarter/hello-gl-ch3 19

"Hello World" in OpenGL 2.0, with matrix transformations

jckarter/ch5-flag 7

Flag demo for Modern OpenGL intro ch5

jckarter/dgen-sdl 7

Ancient Sega Genesis/MegaDrive emulator

jckarter/durians 5

C++11 helper libraries

jckarter/BattleMints 4

action game for iPhone

push eventapple/swift

Joe Groff

commit sha 577f83a26021a9a4d2c1d32a2935d1d69155da69

SIL: Type lowering for imported ObjC async decls. When lowering the type for `@objc` entry points of async declarations, restore the original ObjC signature with the completion handler argument in the lowered SIL type.

view details

Joe Groff

commit sha 06c95cc106970b26969975aaf8bbe4f28ec72977

Add a mangling for completion block implementation functions.

view details

Joe Groff

commit sha 7ab9e87b68336a382bceaaa87c654b546370f7ab

SILGen: Stub out support for invoking foreign async methods. Allow SILGen to not crash when invoking foreign async methods by emitting `undef` for the completion callback going into the call, and for the results that would be channeled back through awaiting the continuation.

view details

Joe Groff

commit sha 096828e5abfeccf1b21bdcbcb1cf6e4186cfe246

Merge pull request #34358 from jckarter/imported-async-type-lowering Type lowering and SILGen for imported ObjC async decls.

view details

push time in 42 minutes

PR merged apple/swift

Reviewers
Type lowering and SILGen for imported ObjC async decls.

Type lowering and (todo) SILGen support for calling ObjC declarations imported as async.

+591 -247

10 comments

19 changed files

jckarter

pr closed time in 42 minutes

pull request commentapple/swift

[WIP] Type lowering and SILGen for imported ObjC async decls.

@swift-ci Please test

jckarter

comment created time in a day

pull request commentapple/swift

[Runtime] Define GOT equivalents for Linux for BuiltinProtocolConformances

Can we even use LLVM IR though? From a quick search it seems that we don't always build with clang, sometimes we build with msvc and I don't believe it can compile ll files (maybe that's just for when building clang? I'm not sure).

The runtime can only be built with the just-built Clang, because upstream clang and msvc do not support the Swift calling convention. It should be fine to use LLVM IR.

Azoy

comment created time in a day

pull request commentapple/swift

[Runtime] Define GOT equivalents for Linux for BuiltinProtocolConformances

Maybe it would be more portable to write the assembly as a .ll file? LLVM ought to be able to generate the proper relocations for all of our target platforms.

Azoy

comment created time in 2 days

PullRequestReviewEvent

pull request commentapple/swift

[Runtime] Define GOT equivalents for Linux for BuiltinProtocolConformances

ELF assemblers do support GOT relative references, but the syntax is different. @GOT should work.

Azoy

comment created time in 2 days

pull request commentapple/swift

[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples

@Azoy The ELF syntax is @GOT instead of @GOTPCREL, IIRC.

Azoy

comment created time in 2 days

pull request commentapple/swift

[WIP] Type lowering and SILGen for imported ObjC async decls.

@swift-ci Please test

jckarter

comment created time in 2 days

push eventjckarter/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

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

Martin Boehme

commit sha 33e8c717f2682b913eb04e1c7746c84315be90ef

Update comment in VisitCXXRecordDecl().

view details

Martin Boehme

commit sha 7e8ea120701b33958a1adca9e885a99f5d583607

Respond to review comments.

view details

Martin Boehme

commit sha 1ce3753d08522cefe255f4acf498dba5085aa60a

Another response to review comments.

view details

push time in 2 days

pull request commentapple/swift

[WIP] Type lowering and SILGen for imported ObjC async decls.

@swift-ci Please test

jckarter

comment created time in 3 days

Pull request review commentapple/swift

[WIP] Type lowering and SILGen for imported ObjC async decls.

 AbstractionPattern TypeConverter::getAbstractionPattern(EnumElementDecl *decl) {   return AbstractionPattern(genericSig, type); } -AbstractionPattern::EncodedForeignErrorInfo-AbstractionPattern::EncodedForeignErrorInfo::encode(-                         const Optional<ForeignErrorConvention> &foreignError) {-  EncodedForeignErrorInfo errorInfo;-  if (foreignError.hasValue()) {-    errorInfo =-      EncodedForeignErrorInfo(foreignError->getErrorParameterIndex(),+AbstractionPattern::EncodedForeignInfo+AbstractionPattern::EncodedForeignInfo::encode(+                         const Optional<ForeignErrorConvention> &foreignError,+                         const Optional<ForeignAsyncConvention> &foreignAsync) {+  // Foreign async convention takes precedence.+  if (foreignAsync.hasValue()) {+    return EncodedForeignInfo(EncodedForeignInfo::Async,+                              foreignAsync->completionHandlerParamIndex(),+                              foreignAsync->completionHandlerErrorParamIndex());+  } else if (foreignError.hasValue()) {+    return EncodedForeignInfo(EncodedForeignInfo::Error,+                              foreignError->getErrorParameterIndex(),                               foreignError->isErrorParameterReplacedWithVoid(),                               foreignError->stripsResultOptionality());

For now, I can have it throw up a diagnostic if this case comes up. It shouldn't be too hard to add support for handling either a synchronous or async error once the basic support is implemented.

jckarter

comment created time in 3 days

PullRequestReviewEvent

push eventjckarter/swift

Joe Groff

commit sha bc4b99e79d1b2bc88f6129bed3919097a09d69e4

Add a mangling for completion block implementation functions.

view details

Joe Groff

commit sha 2b5659ea14bc1ce025aa0678cf33c7933b9860ba

SILGen: Stub out support for invoking foreign async methods. Allow SILGen to not crash when invoking foreign async methods by emitting `undef` for the completion callback going into the call, and for the results that would be channeled back through awaiting the continuation.

view details

push time in 3 days

pull request commentapple/swift

[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples

Should be good to go. Thanks @Azoy !

Azoy

comment created time in 3 days

pull request commentapple/swift

[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples

@Azoy Have you asked for commit access yet? If you have commit access then you ought to be able to trigger CI by yourself.

Azoy

comment created time in 6 days

PR opened apple/swift

Reviewers
[WIP] Type lowering and SILGen for imported ObjC async decls.

Type lowering and SILGen support for calling ObjC declarations imported as async.

+383 -127

0 comment

7 changed files

pr created time in 10 days

create barnchjckarter/swift

branch : imported-async-type-lowering

created branch time in 10 days

push eventapple/swift

Joe Groff

commit sha 3364c51b1d53fd22a3adbaf3d406bd6685535221

SIL: Verify invariants of async_continuation instructions. - Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend

view details

Joe Groff

commit sha aef8f503d88a12dec047c4e3a6383bf8f0cb6d51

Merge pull request #34210 from jckarter/async-await-sil-verifier SIL: Verify invariants of async_continuation instructions.

view details

push time in 10 days

PR merged apple/swift

SIL: Verify invariants of async_continuation instructions.
  • Enforce types of continuations and resume/error BBargs for await
  • Can't access the continuation again or exit the function mid-suspend
+151 -53

18 comments

6 changed files

jckarter

pr closed time in 10 days

pull request commentapple/swift

[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples

@Azoy Yeah, I think @compnerd set it up to add dllimport/dllexport automatically, but you might need to use the right abstraction to do so. Maybe he can help if you can't find it yourself.

Azoy

comment created time in 13 days

pull request commentapple/swift

[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples

Do we mark the symbol as dllimport when targeting PE platforms?

Azoy

comment created time in 13 days

pull request commentapple/swift

[Parse] Parse opaque result types in closure signature position

Looks good to me. Thanks @rintaro!

rintaro

comment created time in 17 days

pull request commentapple/swift

Add a -emit-dead-strippable-symbols flag that emits functions/variable/metadata in a dead_strip-friendly way.

What happens if we remove even the llvm.compiler.used annotation?

kubamracek

comment created time in 17 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test OS X

jckarter

comment created time in 17 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test OS X

jckarter

comment created time in 17 days

push eventjckarter/swift

Joe Groff

commit sha 3364c51b1d53fd22a3adbaf3d406bd6685535221

SIL: Verify invariants of async_continuation instructions. - Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend

view details

push time in 20 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test

jckarter

comment created time in 20 days

PullRequestReviewEvent

Pull request review commentapple/swift

SIL: Verify invariants of async_continuation instructions.

 MultipleValueInstruction *MultipleValueInstructionResult::getParent() {   return reinterpret_cast<MultipleValueInstruction *>(value); } +/// Returns true if evaluation of this node may cause suspension of an+/// async task.+bool SILNode::maySuspend() const {

Alright, I'll move it to SILInstruction.

jckarter

comment created time in 20 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test

jckarter

comment created time in 20 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

Thanks for checking my work. I fixed the logic issues; how's this look now?

jckarter

comment created time in 20 days

push eventjckarter/swift

Joe Groff

commit sha 5b1ddf661615ac2b29c9656158ff25042a642fdb

SIL: Verify invariants of async_continuation instructions. - Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend

view details

push time in 20 days

Pull request review commentapple/swift

SIL: Verify invariants of async_continuation instructions.

 MultipleValueInstruction *MultipleValueInstructionResult::getParent() {   return reinterpret_cast<MultipleValueInstruction *>(value); } +/// Returns true if evaluation of this node may cause suspension of an+/// async task.+bool SILNode::maySuspend() const {

Well, it doesn't seem harmful to put it on SILNode either, to save a cast if all you do have is a SILValue.

jckarter

comment created time in 20 days

PullRequestReviewEvent

pull request commentapple/swift-evolution

Fix double addressing

Thanks @an0!

an0

comment created time in 21 days

push eventapple/swift-evolution

Ling Wang

commit sha 218f37d0507cc02d894d1152179a53b2c02e6d7d

Fix double addressing

view details

Joe Groff

commit sha 513e694e70fc6e4d943783e75f6e86931dd93fe4

Merge pull request #1196 from an0/patch-1 Fix double addressing

view details

push time in 21 days

PR merged apple/swift-evolution

Reviewers
Fix double addressing
+1 -1

0 comment

1 changed file

an0

pr closed time in 21 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test OS X

jckarter

comment created time in 21 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@rjmccall @theblixguy Thanks for the feedback! How's this look now?

jckarter

comment created time in 22 days

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test

jckarter

comment created time in 22 days

push eventjckarter/swift

Joe Groff

commit sha 9d44102a98da638d050e6129d6294e556e90daff

SIL: Verify invariants of async_continuation instructions. - Enforce types of continuations and resume/error BBargs for await - Can't access the continuation again or exit the function mid-suspend

view details

push time in 22 days

Pull request review commentapple/swift

SIL: Verify invariants of async_continuation instructions.

 MultipleValueInstruction *MultipleValueInstructionResult::getParent() {   return reinterpret_cast<MultipleValueInstruction *>(value); } +/// Returns true if evaluation of this node may cause suspension of an+/// async task.+bool SILNode::maySuspend() const {+  // await_async_continuation always suspends the current task.+  if (isa<AwaitAsyncContinuationInst>(this))+    return true;+  +  // Fully applying an async function may suspend the caller.+  if (auto i = dyn_cast<SILInstruction>(this)) {+    if (isa<FullApplySite>(i)) {

Thanks. The dyn_cast half-implementation seems like a bit of an attractive nuisance.

jckarter

comment created time in 22 days

PullRequestReviewEvent

pull request commentapple/swift

SIL: Verify invariants of async_continuation instructions.

@swift-ci Please test

jckarter

comment created time in 23 days

PR opened apple/swift

Reviewers
SIL: Verify invariants of async_continuation instructions.
  • Enforce types of continuations and resume/error BBargs for await
  • Can't access the continuation again or exit the function mid-suspend
+217 -2

0 comment

3 changed files

pr created time in 23 days

create barnchjckarter/swift

branch : async-await-sil-verifier

created branch time in 23 days

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@rjmccall I'm working on the verifier checks in the next commit.

jckarter

comment created time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@compnerd You should be able to add REQUIRES: concurrency to the test to disable it if _Concurrency is not currently built on the Windows bots.

jckarter

comment created time in a month

push eventapple/swift

Joe Groff

commit sha a664a33b52680bca4c80d6749583a86da6bac902

SIL: Add instructions to represent async suspend points. `get_async_continuation[_addr]` begins a suspend operation by accessing the continuation value that can resume the task, which can then be used in a callback or event handler before executing `await_async_continuation` to suspend the task.

view details

Joe Groff

commit sha 95f1bd3bf8210e0d584f879770e2ad4142100d0e

Merge pull request #34142 from jckarter/async-await-sil-instructions SIL: Add instructions to represent async suspend points.

view details

push time in a month

PR merged apple/swift

Reviewers
SIL: Add instructions to represent async suspend points.

get_async_continuation[_addr] begins a suspend operation by accessing the continuation value that can resume the task, which can then be used in a callback or event handler before executing await_async_continuation to suspend the task.

+736 -47

13 comments

29 changed files

jckarter

pr closed time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test Linux

jckarter

comment created time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test Linux

jckarter

comment created time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test

jckarter

comment created time in a month

push eventjckarter/swift

Joe Groff

commit sha a664a33b52680bca4c80d6749583a86da6bac902

SIL: Add instructions to represent async suspend points. `get_async_continuation[_addr]` begins a suspend operation by accessing the continuation value that can resume the task, which can then be used in a callback or event handler before executing `await_async_continuation` to suspend the task.

view details

push time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test

jckarter

comment created time in a month

Pull request review commentapple/swift

SIL: Add instructions to represent async suspend points.

 public struct PartialAsyncTask {    public func run() { } }+++public struct UnsafeContinuation<T> {

Sure. Since PartialAsyncTask wasn't marked as fixed-layout either, I thought we were leaving annotations off of this for now. Do we build the module with library evolution on?

jckarter

comment created time in a month

PullRequestReviewEvent

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test

jckarter

comment created time in a month

push eventjckarter/swift

Doug Gregor

commit sha ab3c5dee3ea2bea8e29d1e70ed8b9e7a2aeff1be

[Concurrency] Introduce Actor protocol to which actor classes all conform. Introduce a new Actor protocol, which is a class-bound protocol with only one requirement: func enqueue(partialTask: PartialAsyncTask) All actor classes implicitly conform to this protocol, and will synthesize a (currently empty) definition of `enqueue(partialTask:)` unless a suitable one is provided explicitly.

view details

Doug Gregor

commit sha 8f3c912f46dc6a2ee3734f741de50bdebf803ec0

[Concurrency] Fix new source file header.

view details

Doug Gregor

commit sha c2b8565a107920f67ed9074fd4d28d3d7a190fa4

[Concurrency] Implicitly synthesize actor queue storage and enqueue. When an actor class has its `enqueue(partialTask:)` implicitly synthesized, also synthesize a stored property for the actor's queue. The type of the property is defined by the _Concurrency library (`_DefaultActorQueue`), and it will be initialized with a call to `_defaultActorQueueCreate` (also provided by the _Concurrency library). Also synthesize the body of the implicitly-generated `enqueue(partialTask:)`, which will be a call to `_defaultActorQueueEnqueuePartialTask(actor:queue:partialTask:)`. Together, all of these allow us to experiment with the form of the queue and the queue operation without affecting the type checker. When `enqueue(partialTask:)` is not implicitly synthesized, the queue storage is not synthesized either. In such cases, the user has taken over the execution of tasks for the actor, rather than using the default implementation.

view details

Doug Gregor

commit sha aeef419de894d646132ce1a11fca61c8d8d9e536

[Concurrency] Ensure that enqueue(partialTask:) is first in actor vtables. Actor classes never have non-actor superclasses, so we can ensure that all actor classes have a common vtable prefix for the `enqueue(partialTask:)` operation. This allows us to treat all actor classes uniformly, without having to go through the Actor witness table every time.

view details

Doug Gregor

commit sha 34996bf9a6b58127c3e4a706329c53be3ba6dd0f

[Concurrency] Give Actor enqueue(partialTask:) its own ptrauth discriminator. For actor class's implementations of `enqueue(partialTask:)`, use a fixed ptrauth discriminator. Paired with the fixed vtable location, this allows one to invoke this operation on any native actor instance without knowing the specific type.

view details

Doug Gregor

commit sha e5c1491c6a77a21c9a6c2465de782d4777e31903

[Concurrency] Ban actor-isolated operations from being @objc. Actor-isolated operations must not be directly accessible from anywhere that is not already guaranteed to be running within the actor context. Prevent such operations from being `@objc`, because that would allow Objective-C code to violate actor isolation.

view details

Doug Gregor

commit sha 1e040ac3235c7cb0d68a41460aafcf6ffd76ea6c

[Concurrency] Note that 'actor' is a decl modifier, not an attribute.

view details

Doug Gregor

commit sha 72bf83653a8d4af599538ac53af0e7dd85c24722

[Concurrency] Allow actor classes to inherit from NSObject. NSObject is guaranteed to have no state and no Swift vtable, and is necessary for Swift classes to implement the NSObject protocol. Allow it (and only it) as the superclass of an actor class, so that actor classes can be exposed to Objective-C.

view details

Doug Gregor

commit sha 592a5e1ce3e202c0d3d17aab8e5e2ce4c4e7c628

[Concurrency] Actor is not an attribute

view details

Michael Gottesman

commit sha c3bc8e8ef93f4ad5d7eb39bb0334bc00bef8de74

[ownership] Move ownership elimination on the stdlib passed lower aggregate instrs.

view details

Doug Gregor

commit sha 75b18ad90b7d810fe3ee8793e2c12ed0107e155e

Merge pull request #34111 from DougGregor/concurrency-actor-protocol [Concurrency] Introduce Actor protocol to which actor classes all conform

view details

Michael Gottesman

commit sha 48b73fdabf3372f5c263418001b86f3502a39370

Merge pull request #34128 from gottesmm/pr-87b3cae407e80a1fb5e3ad4de714847cf43d0439 [ownership] Move ownership elimination on the stdlib passed lower aggregate instrs.

view details

Michael Gottesman

commit sha 4c8d09feb3e527569ea9c5ba026bb7ea59138c14

[ownership] Move ownership lowering past SROA. I already updated SROA for this and we already have tests/etc. We have just been waiting on some other passes to be moved afterwards.

view details

Michael Gottesman

commit sha 8bc6f83dc1a8a546bbc53ddc4f1d74fe1172a08f

Merge pull request #34134 from gottesmm/pr-d16ec3e1fe4adcc9f0993211cdbc57fd7024a93e [ownership] Move ownership lowering past SROA.

view details

Joe Groff

commit sha a7076bf28ed7bb202c081cfb42c5fdda392f9b1e

SIL: Add instructions to represent async suspend points. `get_async_continuation[_addr]` begins a suspend operation by accessing the continuation value that can resume the task, which can then be used in a callback or event handler before executing `await_async_continuation` to suspend the task.

view details

push time in a month

pull request commentapple/swift

SIL: Add instructions to represent async suspend points.

@swift-ci Please test

jckarter

comment created time in a month

PR opened apple/swift

Reviewers
SIL: Add instructions to represent async suspend points.

get_async_continuation[_addr] begins a suspend operation by accessing the continuation value that can resume the task, which can then be used in a callback or event handler before executing await_async_continuation to suspend the task.

+736 -47

0 comment

30 changed files

pr created time in a month

create barnchjckarter/swift

branch : async-await-sil-instructions

created branch time in a month

push eventapple/swift

Joe Groff

commit sha 023066c1966c63ab3b7a4baee31ac24d29b7de36

SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types. When lowering the SILConstantInfo for a closure implementation type with captures, we are more conservative about substituting opaque types in the capture, since the underlying types may only be available in the local context. This means the SILConstantInfo type may not in fact be exactly what you get from `SILFunction::getFunctionTypeInContext` referencing the implementation function from its originating context, since those opaque types will be substituted in the local context. Fixes SR-13480 | rdar://problem/68159831.

view details

Joe Groff

commit sha 6a597d4d04f11f129ffe06422ab33c535ca64a11

Merge pull request #33945 from jckarter/serialized-capture-opaque-type-subst-assert SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

view details

push time in a month

PR merged apple/swift

SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

When lowering the SILConstantInfo for a closure implementation type with captures, we are more conservative about substituting opaque types in the capture, since the underlying types may only be available in the local context. This means the SILConstantInfo type may not in fact be exactly what you get from SILFunction::getFunctionTypeInContext referencing the implementation function from its originating context, since those opaque types will be substituted in the local context.

Fixes SR-13480 | rdar://problem/68159831.

+20 -2

1 comment

2 changed files

jckarter

pr closed time in a month

push eventapple/swift

Joe Groff

commit sha 57215cb17f9312187d59b7c2465a10f4682bf8f3

SIL.rst: Add documentation for async function representation. Unlike our existing coroutines, async functions run independently within an async coroutine context, and don't directly yield values back and forth. They therefore mostly behave like normal functions with only an `@async` annotation to indicate the presence of async suspend points. The `withUnsafeContinuation` primitive requires some instructions to represent the operation that prepares the continuation to be resumed, which will be represented by `begin_async_continuation`...`await_async_continuation` regions.

view details

Joe Groff

commit sha 29587ac766e596a4f154ce5c0889c43978e19f77

Revise with feedback from John and Andy

view details

Joe Groff

commit sha e2dfe3a334333b742af60bd513bdfca89c2c5bf1

Add example of `withUnsafeContinuation` lowering to SIL

view details

Joe Groff

commit sha e4b6f8bccabcc9262597265d1ee650d3789f3232

More feedback: ownership of bbargs, begin -> get_async_continuation

view details

Joe Groff

commit sha 13f86414102bee69b6302e1b0e6a89237e5e3128

Merge pull request #33994 from jckarter/sil-async-documentation SIL.rst: Add documentation for async function representation.

view details

push time in a month

PR merged apple/swift

SIL.rst: Add documentation for async function representation.

Unlike our existing coroutines, async functions run independently within an async coroutine context, and don't directly yield values back and forth. They therefore mostly behave like normal functions with only an @async annotation to indicate the presence of async suspend points. The withUnsafeContinuation primitive requires some instructions to represent the operation that prepares the continuation to be resumed, which will be represented by begin_async_continuation...await_async_continuation regions.

+208 -13

8 comments

1 changed file

jckarter

pr closed time in a month

pull request commentapple/swift

SIL.rst: Add documentation for async function representation.

Alright, I revised begin to get_async_continuation, and clarified the ownership of the bbargs. Any other concerns?

jckarter

comment created time in a month

pull request commentapple/swift

SIL.rst: Add documentation for async function representation.

@swift-ci Please smoke test

jckarter

comment created time in a month

push eventjckarter/swift

Joe Groff

commit sha e4b6f8bccabcc9262597265d1ee650d3789f3232

More feedback: ownership of bbargs, begin -> get_async_continuation

view details

push time in a month

pull request commentapple/swift

SIL.rst: Add documentation for async function representation.

get_async_continuation seems reasonable. Hopefully the verifier can enforce the constraints well enough to help people understand what's going on if it isn't evident from the instruction names themselves

jckarter

comment created time in a month

Pull request review commentapple/swift

SIL.rst: Add documentation for async function representation.

 undefined behavior if the global variable has already been initialized.  The type operand must be a lowered object type. +begin_async_continuation+````````````````````````++::++  sil-instruction ::= 'begin_async_continuation' '[throws]'? sil-type++  %0 = begin_async_continuation $T

How hard would it be to add multiple results later if we decide it's useful? For now, YAGNI seems prudent.

jckarter

comment created time in a month

PullRequestReviewEvent

Pull request review commentapple/swift

SIL.rst: Add documentation for async function representation.

 destination (if it returns with ``throw``).  The rules on generic substitutions are identical to those of ``apply``. +await_async_continuation+````````````````````````++::++  sil-terminator ::= 'await_async_continuation' sil-value+                        ',' 'resume' sil-identifier+                        (',' 'error' sil-identifier)?++  await_async_continuation %0 : $UnsafeContinuation<T>, resume bb1+  await_async_continuation %0 : $UnsafeThrowingContinuation<T>, resume bb1, error bb2++  bb1(%1 : $T):

I said in the text: " The value of the resume argument is owned by the current function." Is there a way I can make it clearer?

jckarter

comment created time in a month

PullRequestReviewEvent

push eventjckarter/swift

Joe Groff

commit sha e2dfe3a334333b742af60bd513bdfca89c2c5bf1

Add example of `withUnsafeContinuation` lowering to SIL

view details

push time in a month

pull request commentapple/swift

SIL.rst: Add documentation for async function representation.

I revised the text a bit; this time I stop trying to discuss async functions as a kind of coroutine, and clarify the semantics of await_async_continuation when the continuation is resumed before it's awaited.

jckarter

comment created time in a month

push eventjckarter/swift

Joe Groff

commit sha 29587ac766e596a4f154ce5c0889c43978e19f77

Revise with feedback from John and Andy

view details

push time in a month

Pull request review commentapple/swift

SIL.rst: Add documentation for async function representation.

 Coroutine Types  A coroutine is a function which can suspend itself and return control to its caller without terminating the function.  That is, it does not need to-obey a strict stack discipline.--SIL supports two kinds of coroutine: ``@yield_many`` and ``@yield_once``.-Either of these attributes may be written before a function type to-indicate that it is a coroutine type.--A coroutine type may declare any number of *yielded values*, which is to+obey a strict stack discipline. Different kinds of coroutines in SIL have+different representations, reflecting the different capabilities and+structural constraints of different language-level features:

Perhaps trying to discuss them as a kind of coroutine only serves to confuse. Thinking of them as just another axis of function type might be easier to understand; I'll try that.

jckarter

comment created time in a month

PullRequestReviewEvent

Pull request review commentapple/swift

SIL.rst: Add documentation for async function representation.

 undefined behavior if the global variable has already been initialized.  The type operand must be a lowered object type. +begin_async_continuation+````````````````````````++::++  sil-instruction ::= 'begin_async_continuation' '[throws]'? sil-type++  %0 = begin_async_continuation $T+  %0 = begin_async_continuation [throws] $U++Begins a suspension of an ``@async`` function. This instruction can only be+used inside an ``@async`` function. The result of the instruction is an+``UnsafeContinuation<T>`` value, where ``T`` is the formal type argument to the+instruction, or an ``UnsafeThrowingContinuation<T>`` if the instruction

We could also just say that resume values are always maximally abstracted, which avoids the need to deal with reabstraction and the representational complexities of dealing with another special-case lowered generic parameter type. To me, the benefits of being able to use a better abstraction pattern across resume points seem pretty marginal.

jckarter

comment created time in a month

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentapple/swift

SIL.rst: Add documentation for async function representation.

Thanks for writing these docs. At the SIL level, explaining async coroutines in terms of @async functions confuses me. Calling an @async function will require generating a coroutine, but the SIL design actually hides that. (I think most people reading this will initially assume that these instructions are used to create a coroutine for calling @async functions, which is backward).

Maybe this is a matter of different perspective, whether you consider the "coroutine" to be the notional execution context that persists across async calls, or to be the mechanical LLVM coroutine lowering goop. I guess I'm speaking more in terms of the former than the latter—as I see it, the LLVM coroutine splitting is an implementation detail, whereas the Task that async functions run in is part of the programming model. An async function doesn't represent a whole Task/coroutine unto itself, but a piece of work that can run on that Task.

Instead, here we're talking about any function that may suspend execution in some way that does not involve calling an @async function. It may be worth pointing out that calling an @async function implicitly generates a coroutine in a way that's hidden from SIL, while these instructions are for other kinds of suspension points that aren't naturally handled by an @async function call, namely withUnsafeContinuation. As a footnote, we can say that they are currently limited to @async function bodies for implementation reasons that are totally unrelated to SIL design.

I guess it isn't clear, but the intent of these instructions was to give something for withUnsafeContinuation specifically to lower to, as John described in this forum post. I can add a more explicit example of how withUnsafeContinuation lowers to these SIL instructions. The hope is that withUnsafeContinuation's operation block can be inlined into the caller in most situations.

In SIL, there's no reason that a synchronous function can't suspend. I think that will be important to support at the language-level when we can statically determine the executor.

Could you give me an example of what you have in mind. As I understand it, anything associated with an executor that might suspend ought to be async in the language design. What differences would there be between @async and @maysuspend?

Regarding the implications for SIL passes, a lot seems to be hidden in this statement:

It is possible for a continuation to be resumed before await_async_continuation. In this case, the resume operation returns immediately, and await_async_continuation immediately transfers control to its resume or error successor block, with the resume or error value that the continuation was resumed with. We won't be able to allow side-effect free code motion across the await, which is something we've never had to content with. Do we need to add a constraint that values defined within the suspend region can't be used outside the suspend region?

await_async_continuation shouldn't be any more opaque to optimization than a try_apply. Code outside of the task can't manipulate the function's local state, but can have arbitrary global side effects, like a synchronous call.

Reading this back, I see it sounds like it's implying that resuming a continuation before await_async_continuation immediately transfers control to the await_async_continuation successor, which isn't what I meant to say—the resume operation returns immediately to its caller after priming the await, and then later, when the await_async_continuation executes, it immediately goes to the resume/error successor using the value it was primed with. I'll reword it to clarify.

Thanks for taking a look and giving me your feedback, Andy!

jckarter

comment created time in a month

PR opened apple/swift

Reviewers
SIL.rst: Add documentation for async function representation.

Unlike our existing coroutines, async functions run independently within an async coroutine context, and don't directly yield values back and forth. They therefore mostly behave like normal functions with only an @async annotation to indicate the presence of async suspend points. The withUnsafeContinuation primitive requires some instructions to represent the operation that prepares the continuation to be resumed, which will be represented by begin_async_continuation...await_async_continuation regions.

+188 -18

0 comment

1 changed file

pr created time in a month

push eventjckarter/swift

Joe Groff

commit sha 57215cb17f9312187d59b7c2465a10f4682bf8f3

SIL.rst: Add documentation for async function representation. Unlike our existing coroutines, async functions run independently within an async coroutine context, and don't directly yield values back and forth. They therefore mostly behave like normal functions with only an `@async` annotation to indicate the presence of async suspend points. The `withUnsafeContinuation` primitive requires some instructions to represent the operation that prepares the continuation to be resumed, which will be represented by `begin_async_continuation`...`await_async_continuation` regions.

view details

push time in a month

create barnchjckarter/swift

branch : sil-async-documentation

created branch time in a month

push eventapple/swift-evolution

Joe Groff

commit sha e24e42d95c71e32ff4b7ac9c0d0a1a02861001b7

Accept SE-288

view details

push time in a month

push eventapple/swift-evolution

Joe Groff

commit sha 95f220b301e20ecded239122b9fe89819e00a033

Remove expired unimplemented part of SE-155

view details

push time in a month

push eventapple/swift

Joe Groff

commit sha c3a1c7fddd9fd9b9cdfc93a250f555d9c04b3cb1

SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types. When lowering the SILConstantInfo for a closure implementation type with captures, we are more conservative about substituting opaque types in the capture, since the underlying types may only be available in the local context. This means the SILConstantInfo type may not in fact be exactly what you get from `SILFunction::getFunctionTypeInContext` referencing the implementation function from its originating context, since those opaque types will be substituted in the local context. Fixes SR-13480 | rdar://problem/68159831.

view details

Joe Groff

commit sha 1eda5ab329d17d3900665d673adc4964eb4647c3

Merge pull request #33949 from jckarter/serialized-capture-opaque-type-subst-assert-5.3 [5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

view details

push time in a month

PR merged apple/swift

[5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types. r5.3

Explanation: An assertion failure would trigger spuriously in some circumstances where a public inlinable function contained a closure that captured a value with an opaque result type.

Scope: Incorrect assertion failure; regression from 5.2

Risk: Low; no behavior change to asserts-disabled builds

Reviewed by: @aschwaighofer

Issue: SR-13480 | rdar://problem/68159831

+20 -2

2 comments

2 changed files

jckarter

pr closed time in a month

pull request commentapple/swift

[5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

@swift-ci Please nominate

jckarter

comment created time in a month

pull request commentapple/swift

[5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

@swift-ci Please test

jckarter

comment created time in a month

PR opened apple/swift

[5.3] SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

Explanation: An assertion failure would trigger spuriously in some circumstances where a public inlinable function contained a closure that captured a value with an opaque result type.

Scope: Incorrect assertion failure; regression from 5.2

Risk: Low; no behavior change to asserts-disabled builds

Reviewed by: @aschwaighofer

Issue: SR-13480 | rdar://problem/68159831

+20 -2

0 comment

2 changed files

pr created time in a month

create barnchjckarter/swift

branch : serialized-capture-opaque-type-subst-assert-5.3

created branch time in a month

pull request commentapple/swift

SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

@swift-ci Please test

jckarter

comment created time in a month

PR opened apple/swift

Reviewers
SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.

When lowering the SILConstantInfo for a closure implementation type with captures, we are more conservative about substituting opaque types in the capture, since the underlying types may only be available in the local context. This means the SILConstantInfo type may not in fact be exactly what you get from SILFunction::getFunctionTypeInContext referencing the implementation function from its originating context, since those opaque types will be substituted in the local context.

Fixes SR-13480 | rdar://problem/68159831.

+20 -2

0 comment

2 changed files

pr created time in a month

create barnchjckarter/swift

branch : serialized-capture-opaque-type-subst-assert

created branch time in a month

more