[Concurrency] Make Job/AsyncTask minimally compatible with dispatch object layout

Create a TargetDispatchClassMetadata for Swift metadata that also has a dispatch-compatible vtable. Dispatch leaves room for ObjC class metadata so the two regions don't overlap. (The vtable currently consists of a single dummy entry; this will be filled out later.)

Rearrange the Job and AsyncTask hierarchy so that AsyncTask inherits only from Job, which in turn inherits from HeapObject. This gives all Job instances a dispatch-compatible isa field. It also gives them a refcount word, which is wasted on instances that aren't AsyncTask instances. Maybe we can find some use for that space in the future.

rdar://75227953
This commit is contained in:
Mike Ash
2021-02-16 17:06:05 -05:00
parent bdacb68b83
commit bd62fdb2db
8 changed files with 71 additions and 22 deletions

View File

@@ -619,8 +619,10 @@ IRGenModule::IRGenModule(IRGenerator &irgen,
SwiftTaskGroupPtrTy = Int8PtrTy; // we pass it opaquely (TaskGroup*)
SwiftExecutorPtrTy = SwiftExecutorTy->getPointerTo(DefaultAS);
SwiftJobTy = createStructType(*this, "swift.job", {
RefCountedStructTy, // object header
Int8PtrTy, Int8PtrTy, // SchedulerPrivate
SizeTy, // flags
Int8PtrTy // execution function pointer
FunctionPtrTy, // RunJob/ResumeTask
});
SwiftJobPtrTy = SwiftJobTy->getPointerTo();