Skip to content

[Pseudo-ObjC] Render @autoreleasepool blocks - #8525

Open
AngeloD2022 wants to merge 1 commit into
Vector35:devfrom
AngeloD2022:pseudo-objc-autoreleasepool
Open

[Pseudo-ObjC] Render @autoreleasepool blocks#8525
AngeloD2022 wants to merge 1 commit into
Vector35:devfrom
AngeloD2022:pseudo-objc-autoreleasepool

Conversation

@AngeloD2022

@AngeloD2022 AngeloD2022 commented Sep 6, 2026

Copy link
Copy Markdown

Translate autorelease pool runtime function calls to @autoreleasepool {...} blocks.

Original Objective-C snippet:

for (NSUInteger itemNo = 1; itemNo <= 3; itemNo++) {
    @autoreleasepool {
        NSString *item = [NSString stringWithFormat:@"batch %lu, item %lu",
                            (unsigned long)batchNo,
                            (unsigned long)itemNo];
        NSString *displayItem = [item uppercaseString];
        [items addObject:displayItem];
    }
}

Pseudo-C snippet:

for (int64_t i = 1; i <= 3; i += 1)
{
    void* context = _objc_autoreleasePoolPush();
    int64_t x0;
    int64_t var_80_1 = x0;
    i_1 = i;
    id location_2 = _objc_retainAutoreleasedReturnValue(_objc_msgSend(
        _OBJC_CLASS_$_NSString, "stringWithFormat:", &cfstr_batch_%lu,_item_%lu));
    int64_t location_1 = _objc_retainAutoreleasedReturnValue(_objc_msgSend(
        location_2, "uppercaseString"));
    _objc_msgSend(var_20, "addObject:", location_1);
    _objc_storeStrong(&location_1, nullptr);
    _objc_storeStrong(&location_2, nullptr);
    _objc_autoreleasePoolPop(context);
}

Equivalent Pseudo-Objective-C:

for (int64_t i = 1; i <= 3; i += 1)
{
    @autoreleasepool
    {
        int64_t x0;
        int64_t var_80_1 = x0;
        i_1 = i;
        id location_2 =
            [[NSString stringWithFormat:@"batch %lu, item %lu"] retain];
        int64_t location_1 = [[location_2 uppercaseString] retain];
        [var_20 addObject:location_1];
        _objc_storeStrong(&location_1, nullptr);
        _objc_storeStrong(&location_2, nullptr);
    }
}

@AngeloD2022
AngeloD2022 marked this pull request as ready for review September 6, 2026 22:58
@bdash
bdash self-requested a review September 7, 2026 00:13
@AngeloD2022
AngeloD2022 force-pushed the pseudo-objc-autoreleasepool branch from 4c9e11b to 47e0fd0 Compare September 7, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant