Skip to content

v0.20.0

Choose a tag to compare

@lynnswap lynnswap released this 13 Nov 02:53
a3f4048

Added

  • Pass a retained image wherever images are selected with ImageSelector.image(_:). This includes resolve(_:in:), NativeSymbolRequest.imageScopes, resolveImages(matching:), and the importer scope of hooks.
  • Select a C function by its exact spelling when its layout is described at run time, with DynamicNativeFunctionRequest.function(linkerName:signature:) and function(machOName:signature:).

Changed

  • ABIRuntime and NativeSwiftType are Sendable final classes. They were actors whose members were all nonisolated.
  • Hooks and replacements report their outcomes through one set of types: NativeHookInvocationError, NativeHookSlotStatus, and NativePointerSlotMutation.
  • Imported hooks and imported replacements of a Swift function or method use the runtime that resolved the handle. Earlier releases used the shared runtime's import indexes unless using: was passed.
  • The C++ wrapper names the shared runtime abi_bridge::runtime::shared(), matching ABIRuntime.shared.
  • The documentation of ABIRuntime states what a runtime owns (its resolution caches and image leases), what belongs to the process, and when to create a separate runtime.

Fixed

  • Concurrent calls through Swift handles no longer wait on a process-wide lock once the values involved are tied to the same loaded code. In 0.19.1, a callback invoked from many threads could queue behind that lock.
  • Resolving Swift declarations in large images is faster. In a 13 MB image with 115,000 exports, a function whose result needs an inferred value convention resolves in about 254 ms instead of 438 ms, and a plain function in about 190 ms instead of 227 ms.

Compatibility

This release changes source that uses the APIs below.

  • Retained images. The in: NativeImage overloads of resolve, resolveAndWait, and cxxObject are removed. Replace in: image with in: .image(image). A stored ImageSelector or NativeSymbolRequest that holds .image keeps that image loaded. The from: provider filter of imported hooks, monitors, and replacements rejects .image; keep using .installName, .framework, or .path there.
  • Actors. Code that used ABIRuntime or NativeSwiftType as an actor, for example as an isolated parameter or as any Actor, no longer compiles. Other call sites are unchanged.
  • Hook errors. Replace NativeImportedInvocationError, NativeVirtualInvocationError, and NativeSwiftHookInvocationError with NativeHookInvocationError. NativeObjCMethodHookError no longer has expiredInvocation and wrongThread; catch NativeHookInvocationError for those.
  • Slot status and mutations. Replace the nested Status of NativeImportedFunctionHook, NativeVirtualHook, and NativeSwiftImportedFunctionHook with NativeHookSlotStatus. Replace their nested Mutation types and NativeSwiftReplacementMutation with NativePointerSlotMutation, and read its outcome enum instead of comparing the Int32 status.
  • Swift imported hooks. Remove the using: argument from hookImportedCalls, hookMainActorImportedCalls, prepareImportedReplacement, and prepareImportedReplacementAndWait. A handle resolved by an independent ABIRuntime() now reads that runtime's import indexes.
  • C++. Replace abi_bridge::runtime::current() with abi_bridge::runtime::shared().

Full Changelog: v0.19.1...v0.20.0