From 82e8eaca7db9dc7284e3fb382eecbfbecef7bcb6 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Mon, 29 Sep 2025 17:02:13 -0700 Subject: [ObjC] Add support for removing runtime calls that perform retain count operations A new activity is added that will remove calls to `objc_retain`, `objc_release`, `objc_autorelease`, and related functions. It is disabled by default due to the fact it changes the semantics of the code. It can be enabled on a per-function basis via the Function Settings context menu or command palette entry. Alternatively, it can be enabled in Open with Options or in user settings if a user would prefer it be on for an entire file or for all files they open. For now the activity is only eligible within arm64 binaries. Supporting x86_64 will require matching some slightly different IL patterns. --- plugins/workflow_objc/src/workflow.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'plugins/workflow_objc/src/workflow.rs') diff --git a/plugins/workflow_objc/src/workflow.rs b/plugins/workflow_objc/src/workflow.rs index f411951b..f1054411 100644 --- a/plugins/workflow_objc/src/workflow.rs +++ b/plugins/workflow_objc/src/workflow.rs @@ -69,9 +69,28 @@ pub fn register_activities() -> Result<(), WorkflowRegistrationError> { run(activities::super_init::process), ); + let remove_memory_management_activity = Activity::new_with_action( + activity::Config::action( + "core.function.objectiveC.removeMemoryManagement", + "Obj-C: Remove reference counting calls", + "Remove calls to objc_retain / objc_release / objc_autorelease to simplify the resulting higher-level ILs", + ) + .eligibility( + activity::Eligibility::auto_with_default(false).matching_all_predicates(&[ + activity::ViewType::in_(["Mach-O", "DSCView"]).into(), + activity::Platform::in_(["mac-aarch64", "ios-aarch64"]).into() + ]) + ), + run(activities::remove_memory_management::process), + ); + workflow .activity_after(&inline_stubs_activity, "core.function.translateTailCalls")? .activity_after(&objc_msg_send_calls_activity, &inline_stubs_activity.name())? + .activity_before( + &remove_memory_management_activity, + "core.function.generateMediumLevelIL", + )? .activity_after(&super_init_activity, "core.function.generateMediumLevelIL")? .register_with_config(WORKFLOW_INFO)?; -- cgit v1.3.1