The register's check walked only the public protocols the bundle's classes adopt, so it could not see the class of member macOS 13's Maps died on: a member of Metal's SPI counterpart (MTLLibrarySPI for MTLLibrary), which Metal's own objects adopt and the guest's frameworks send without asking. It now walks each protocol's SPI counterpart too, and adds the members only older guest releases' protocols carry, which the Mac it runs on lacks (tests/protocol_members_releases.txt: macOS 11.7.11, 12.7.6, 13.7.8 and 26.7.2 against 27.0.1). The register lists every SPI member: the forwarders as implemented, the constant answers as Metal's with why, and the rest by what the AMD 5300M's and the Intel 630's objects answer (measured with respondsToSelector:, macOS 26.7.1), counted by class family: pending where both answer (305, to be answered as Metal's), absent where neither does (54) or they differ (6), pending where the oracle's macOS lacks the member (14). A new kind, pending, is checked as absent. The 31 members only older releases carry are absent: no app pass on those releases showed a framework sending one, and the 4 of MTLDeviceSPI are answered there by the device's own IOGPU base. tools/protocol_dump.m dumps a Metal's protocols for the releases list, and tools/oracle/oracle_spi_members.m asks a Mac's own objects for the verdicts and what their getters answer. docs/lessons.md says what the trap was.
45 lines
1.9 KiB
Objective-C
45 lines
1.9 KiB
Objective-C
// protocol_dump: every instance member of every MTL* protocol this process's Metal defines, through
|
|
// the Objective-C runtime: one line per member, "PROTOCOL SELECTOR required|optional", and one per
|
|
// protocol it adopts, "PROTOCOL adopts OTHER". It makes no device and calls no member. Run in each
|
|
// guest macOS and on the Mac that runs the bundle's tests: a member a guest prints for a protocol
|
|
// the bundle's classes adopt (or its SPI counterpart) that the Mac's protocol, with the protocols
|
|
// it adopts, lacks is a line of tests/protocol_members_releases.txt.
|
|
// Build (on a Mac): xcrun clang -arch x86_64 -mmacosx-version-min=11.0 -fobjc-arc
|
|
// -framework Foundation -framework Metal protocol_dump.m -o protocol_dump
|
|
#import <Foundation/Foundation.h>
|
|
#import <Metal/Metal.h>
|
|
#include <objc/runtime.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(void)
|
|
{
|
|
@autoreleasepool {
|
|
// Metal registers its protocols as it loads; naming one makes the linker keep it.
|
|
(void)@protocol(MTLDevice);
|
|
unsigned count = 0;
|
|
Protocol *__unsafe_unretained *protocols = objc_copyProtocolList(&count);
|
|
for (unsigned i = 0; i < count; i++) {
|
|
const char *name = protocol_getName(protocols[i]);
|
|
if (strncmp(name, "MTL", 3) != 0)
|
|
continue;
|
|
for (int required = 1; required >= 0; required--) {
|
|
unsigned n = 0;
|
|
struct objc_method_description *members =
|
|
protocol_copyMethodDescriptionList(protocols[i], required, YES, &n);
|
|
for (unsigned j = 0; j < n; j++)
|
|
printf("%s %s %s\n", name, sel_getName(members[j].name),
|
|
required ? "required" : "optional");
|
|
free(members);
|
|
}
|
|
unsigned m = 0;
|
|
Protocol *__unsafe_unretained *adopted = protocol_copyProtocolList(protocols[i], &m);
|
|
for (unsigned j = 0; j < m; j++)
|
|
printf("%s adopts %s\n", name, protocol_getName(adopted[j]));
|
|
free(adopted);
|
|
}
|
|
free(protocols);
|
|
}
|
|
return 0;
|
|
}
|