diff --git a/crates/objc2/src/__macro_helpers/declared_ivars.rs b/crates/objc2/src/__macro_helpers/declared_ivars.rs index 784e2e6c6..d3ae34a35 100644 --- a/crates/objc2/src/__macro_helpers/declared_ivars.rs +++ b/crates/objc2/src/__macro_helpers/declared_ivars.rs @@ -281,8 +281,14 @@ pub(crate) fn register_with_ivars( let cls = builder.register(); let ivars_offset = if T::HAS_IVARS { + // Monomorphized error handling + // Intentionally not #[track_caller], we expect this error to never occur + fn get_ivar_failed() -> ! { + unreachable!("failed retrieving instance variable on newly declared class") + } + cls.instance_variable(&ivar_name) - .expect("failed retrieving instance variable on newly declared class") + .unwrap_or_else(|| get_ivar_failed()) .offset() } else { // Fallback to an offset of zero. @@ -293,8 +299,14 @@ pub(crate) fn register_with_ivars( }; let drop_flag_offset = if T::HAS_DROP_FLAG { + // Monomorphized error handling + // Intentionally not #[track_caller], we expect this error to never occur + fn get_drop_flag_failed() -> ! { + unreachable!("failed retrieving drop flag instance variable on newly declared class") + } + cls.instance_variable(&drop_flag_name) - .expect("failed retrieving drop flag instance variable on newly declared class") + .unwrap_or_else(|| get_drop_flag_failed()) .offset() } else { // Fall back to an offset of zero. diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s b/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s index 073ed1d6f..2ea0c3e1a 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s @@ -78,9 +78,9 @@ Lloh8: Lloh9: ldr x2, [x8] Lloh10: - adrp x0, l_anon.[ID].22@PAGE + adrp x0, l_anon.[ID].17@PAGE Lloh11: - add x0, x0, l_anon.[ID].22@PAGEOFF + add x0, x0, l_anon.[ID].17@PAGEOFF mov w1, #7 bl SYM(objc2::declare::ClassBuilder::new::GENERATED_ID, 0) cbz x0, LBB4_8 @@ -169,9 +169,9 @@ Lloh41: mov x4, x21 bl SYM(objc2::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) Lloh42: - adrp x0, l_anon.[ID].29@PAGE + adrp x0, l_anon.[ID].24@PAGE Lloh43: - add x0, x0, l_anon.[ID].29@PAGEOFF + add x0, x0, l_anon.[ID].24@PAGEOFF mov w1, #8 bl SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) cbz x0, LBB4_4 @@ -180,9 +180,9 @@ Lloh43: bl SYM(objc2::declare::ClassBuilder::add_protocol::GENERATED_ID, 0) LBB4_4: Lloh44: - adrp x0, l_anon.[ID].30@PAGE + adrp x0, l_anon.[ID].25@PAGE Lloh45: - add x0, x0, l_anon.[ID].30@PAGEOFF + add x0, x0, l_anon.[ID].25@PAGEOFF mov w1, #9 bl SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) cbz x0, LBB4_6 @@ -220,24 +220,24 @@ Lloh53: ret LBB4_7: Lloh54: - adrp x0, l_anon.[ID].24@PAGE + adrp x0, l_anon.[ID].19@PAGE Lloh55: - add x0, x0, l_anon.[ID].24@PAGEOFF + add x0, x0, l_anon.[ID].19@PAGEOFF Lloh56: - adrp x2, l_anon.[ID].26@PAGE + adrp x2, l_anon.[ID].21@PAGE Lloh57: - add x2, x2, l_anon.[ID].26@PAGEOFF + add x2, x2, l_anon.[ID].21@PAGEOFF mov w1, #43 bl SYM(core::panicking::panic::GENERATED_ID, 0) LBB4_8: Lloh58: - adrp x0, l_anon.[ID].22@PAGE + adrp x0, l_anon.[ID].17@PAGE Lloh59: - add x0, x0, l_anon.[ID].22@PAGEOFF + add x0, x0, l_anon.[ID].17@PAGEOFF Lloh60: - adrp x2, l_anon.[ID].28@PAGE + adrp x2, l_anon.[ID].23@PAGE Lloh61: - add x2, x2, l_anon.[ID].28@PAGEOFF + add x2, x2, l_anon.[ID].23@PAGEOFF mov w1, #7 bl SYM(objc2::__macro_helpers::declare_class::failed_declaring_class::GENERATED_ID, 0) .loh AdrpAdd Lloh10, Lloh11 @@ -285,9 +285,9 @@ Lloh63: Lloh64: ldr x2, [x8] Lloh65: - adrp x0, l_anon.[ID].23@PAGE + adrp x0, l_anon.[ID].18@PAGE Lloh66: - add x0, x0, l_anon.[ID].23@PAGEOFF + add x0, x0, l_anon.[ID].18@PAGEOFF mov w1, #9 bl SYM(objc2::declare::ClassBuilder::new::GENERATED_ID, 0) cbz x0, LBB5_6 @@ -401,48 +401,30 @@ Lloh95: ret LBB5_5: Lloh96: - adrp x0, l_anon.[ID].24@PAGE + adrp x0, l_anon.[ID].19@PAGE Lloh97: - add x0, x0, l_anon.[ID].24@PAGEOFF + add x0, x0, l_anon.[ID].19@PAGEOFF Lloh98: - adrp x2, l_anon.[ID].26@PAGE + adrp x2, l_anon.[ID].21@PAGE Lloh99: - add x2, x2, l_anon.[ID].26@PAGEOFF + add x2, x2, l_anon.[ID].21@PAGEOFF mov w1, #43 bl SYM(core::panicking::panic::GENERATED_ID, 0) LBB5_6: Lloh100: - adrp x0, l_anon.[ID].23@PAGE + adrp x0, l_anon.[ID].18@PAGE Lloh101: - add x0, x0, l_anon.[ID].23@PAGEOFF + add x0, x0, l_anon.[ID].18@PAGEOFF Lloh102: - adrp x2, l_anon.[ID].32@PAGE + adrp x2, l_anon.[ID].27@PAGE Lloh103: - add x2, x2, l_anon.[ID].32@PAGEOFF + add x2, x2, l_anon.[ID].27@PAGEOFF mov w1, #9 bl SYM(objc2::__macro_helpers::declare_class::failed_declaring_class::GENERATED_ID, 0) LBB5_7: -Lloh104: - adrp x0, l_anon.[ID].16@PAGE -Lloh105: - add x0, x0, l_anon.[ID].16@PAGEOFF -Lloh106: - adrp x2, l_anon.[ID].18@PAGE -Lloh107: - add x2, x2, l_anon.[ID].18@PAGEOFF - mov w1, #59 - bl SYM(core::option::expect_failed::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) LBB5_8: -Lloh108: - adrp x0, l_anon.[ID].19@PAGE -Lloh109: - add x0, x0, l_anon.[ID].19@PAGEOFF -Lloh110: - adrp x2, l_anon.[ID].20@PAGE -Lloh111: - add x2, x2, l_anon.[ID].20@PAGEOFF - mov w1, #69 - bl SYM(core::option::expect_failed::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) .loh AdrpAdd Lloh65, Lloh66 .loh AdrpLdrGotLdr Lloh62, Lloh63, Lloh64 .loh AdrpAdd Lloh89, Lloh90 @@ -463,10 +445,6 @@ Lloh111: .loh AdrpAdd Lloh96, Lloh97 .loh AdrpAdd Lloh102, Lloh103 .loh AdrpAdd Lloh100, Lloh101 - .loh AdrpAdd Lloh106, Lloh107 - .loh AdrpAdd Lloh104, Lloh105 - .loh AdrpAdd Lloh110, Lloh111 - .loh AdrpAdd Lloh108, Lloh109 .p2align 2 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): @@ -478,37 +456,37 @@ SYM(::call_once::<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): @@ -643,16 +610,16 @@ SYM(<::call_once<::drop, 0) .p2align 2 @@ -715,16 +682,16 @@ SYM( .globl _access_drop_ivars_class .p2align 2 _access_drop_ivars_class: -Lloh158: +Lloh146: adrp x8, __MergedGlobals@PAGE+40 -Lloh159: +Lloh147: add x8, x8, __MergedGlobals@PAGEOFF+40 ldapr x8, [x8] cmp x8, #3 b.ne LBB13_2 -Lloh160: +Lloh148: adrp x8, __MergedGlobals@PAGE+32 -Lloh161: +Lloh149: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret LBB13_2: @@ -735,60 +702,60 @@ LBB13_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh162: +Lloh150: adrp x0, __MergedGlobals@PAGE+40 -Lloh163: +Lloh151: add x0, x0, __MergedGlobals@PAGEOFF+40 -Lloh164: +Lloh152: adrp x3, l_anon.[ID].1@PAGE -Lloh165: +Lloh153: add x3, x3, l_anon.[ID].1@PAGEOFF -Lloh166: - adrp x4, l_anon.[ID].32@PAGE -Lloh167: - add x4, x4, l_anon.[ID].32@PAGEOFF +Lloh154: + adrp x4, l_anon.[ID].27@PAGE +Lloh155: + add x4, x4, l_anon.[ID].27@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh168: +Lloh156: adrp x8, __MergedGlobals@PAGE+32 -Lloh169: +Lloh157: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret - .loh AdrpAdd Lloh158, Lloh159 - .loh AdrpLdr Lloh160, Lloh161 - .loh AdrpLdr Lloh168, Lloh169 - .loh AdrpAdd Lloh166, Lloh167 - .loh AdrpAdd Lloh164, Lloh165 - .loh AdrpAdd Lloh162, Lloh163 + .loh AdrpAdd Lloh146, Lloh147 + .loh AdrpLdr Lloh148, Lloh149 + .loh AdrpLdr Lloh156, Lloh157 + .loh AdrpAdd Lloh154, Lloh155 + .loh AdrpAdd Lloh152, Lloh153 + .loh AdrpAdd Lloh150, Lloh151 .globl _access_drop_ivars .p2align 2 _access_drop_ivars: -Lloh170: +Lloh158: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE -Lloh171: +Lloh159: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x0, x8 ldp x0, x1, [x8] ret - .loh AdrpLdr Lloh170, Lloh171 + .loh AdrpLdr Lloh158, Lloh159 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh172: +Lloh160: adrp x8, __MergedGlobals@PAGE+8 -Lloh173: +Lloh161: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB15_2 -Lloh174: +Lloh162: adrp x8, __MergedGlobals@PAGE -Lloh175: +Lloh163: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret LBB15_2: @@ -799,48 +766,48 @@ LBB15_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh176: +Lloh164: adrp x0, __MergedGlobals@PAGE+8 -Lloh177: +Lloh165: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh178: +Lloh166: adrp x3, l_anon.[ID].0@PAGE -Lloh179: +Lloh167: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh180: - adrp x4, l_anon.[ID].28@PAGE -Lloh181: - add x4, x4, l_anon.[ID].28@PAGEOFF +Lloh168: + adrp x4, l_anon.[ID].23@PAGE +Lloh169: + add x4, x4, l_anon.[ID].23@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh182: +Lloh170: adrp x8, __MergedGlobals@PAGE -Lloh183: +Lloh171: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret - .loh AdrpAdd Lloh172, Lloh173 - .loh AdrpLdr Lloh174, Lloh175 - .loh AdrpLdr Lloh182, Lloh183 - .loh AdrpAdd Lloh180, Lloh181 - .loh AdrpAdd Lloh178, Lloh179 - .loh AdrpAdd Lloh176, Lloh177 + .loh AdrpAdd Lloh160, Lloh161 + .loh AdrpLdr Lloh162, Lloh163 + .loh AdrpLdr Lloh170, Lloh171 + .loh AdrpAdd Lloh168, Lloh169 + .loh AdrpAdd Lloh166, Lloh167 + .loh AdrpAdd Lloh164, Lloh165 .globl _get_class .p2align 2 _get_class: -Lloh184: +Lloh172: adrp x8, __MergedGlobals@PAGE+8 -Lloh185: +Lloh173: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB16_2 -Lloh186: +Lloh174: adrp x8, __MergedGlobals@PAGE -Lloh187: +Lloh175: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret LBB16_2: @@ -851,34 +818,34 @@ LBB16_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh188: +Lloh176: adrp x0, __MergedGlobals@PAGE+8 -Lloh189: +Lloh177: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh190: +Lloh178: adrp x3, l_anon.[ID].0@PAGE -Lloh191: +Lloh179: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh192: - adrp x4, l_anon.[ID].28@PAGE -Lloh193: - add x4, x4, l_anon.[ID].28@PAGEOFF +Lloh180: + adrp x4, l_anon.[ID].23@PAGE +Lloh181: + add x4, x4, l_anon.[ID].23@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh194: +Lloh182: adrp x8, __MergedGlobals@PAGE -Lloh195: +Lloh183: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret - .loh AdrpAdd Lloh184, Lloh185 - .loh AdrpLdr Lloh186, Lloh187 - .loh AdrpLdr Lloh194, Lloh195 - .loh AdrpAdd Lloh192, Lloh193 - .loh AdrpAdd Lloh190, Lloh191 - .loh AdrpAdd Lloh188, Lloh189 + .loh AdrpAdd Lloh172, Lloh173 + .loh AdrpLdr Lloh174, Lloh175 + .loh AdrpLdr Lloh182, Lloh183 + .loh AdrpAdd Lloh180, Lloh181 + .loh AdrpAdd Lloh178, Lloh179 + .loh AdrpAdd Lloh176, Lloh177 .globl _method_simple .p2align 2 @@ -897,23 +864,23 @@ _method_id: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh196: +Lloh184: adrp x8, __MergedGlobals@PAGE+8 -Lloh197: +Lloh185: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB19_2 LBB19_1: -Lloh198: +Lloh186: adrp x8, __MergedGlobals@PAGE -Lloh199: +Lloh187: ldr x0, [x8, __MergedGlobals@PAGEOFF] -Lloh200: +Lloh188: adrp x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGE -Lloh201: +Lloh189: ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGEOFF] -Lloh202: +Lloh190: ldr x1, [x8] bl _objc_msgSend bl _objc_autoreleaseReturnValue @@ -925,29 +892,29 @@ LBB19_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh203: +Lloh191: adrp x0, __MergedGlobals@PAGE+8 -Lloh204: +Lloh192: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh205: +Lloh193: adrp x3, l_anon.[ID].0@PAGE -Lloh206: +Lloh194: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh207: - adrp x4, l_anon.[ID].28@PAGE -Lloh208: - add x4, x4, l_anon.[ID].28@PAGEOFF +Lloh195: + adrp x4, l_anon.[ID].23@PAGE +Lloh196: + add x4, x4, l_anon.[ID].23@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) b LBB19_1 - .loh AdrpAdd Lloh196, Lloh197 - .loh AdrpLdrGotLdr Lloh200, Lloh201, Lloh202 - .loh AdrpAdrp Lloh198, Lloh200 - .loh AdrpLdr Lloh198, Lloh199 - .loh AdrpAdd Lloh207, Lloh208 - .loh AdrpAdd Lloh205, Lloh206 - .loh AdrpAdd Lloh203, Lloh204 + .loh AdrpAdd Lloh184, Lloh185 + .loh AdrpLdrGotLdr Lloh188, Lloh189, Lloh190 + .loh AdrpAdrp Lloh186, Lloh188 + .loh AdrpLdr Lloh186, Lloh187 + .loh AdrpAdd Lloh195, Lloh196 + .loh AdrpAdd Lloh193, Lloh194 + .loh AdrpAdd Lloh191, Lloh192 .globl _method_id_with_param .p2align 2 @@ -976,23 +943,23 @@ _copyWithZone: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh209: +Lloh197: adrp x8, __MergedGlobals@PAGE+8 -Lloh210: +Lloh198: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB21_2 LBB21_1: -Lloh211: +Lloh199: adrp x8, __MergedGlobals@PAGE -Lloh212: +Lloh200: ldr x0, [x8, __MergedGlobals@PAGEOFF] -Lloh213: +Lloh201: adrp x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGE -Lloh214: +Lloh202: ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGEOFF] -Lloh215: +Lloh203: ldr x1, [x8] bl _objc_msgSend ldp x29, x30, [sp, #16] @@ -1003,43 +970,43 @@ LBB21_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh216: +Lloh204: adrp x0, __MergedGlobals@PAGE+8 -Lloh217: +Lloh205: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh218: +Lloh206: adrp x3, l_anon.[ID].0@PAGE -Lloh219: +Lloh207: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh220: - adrp x4, l_anon.[ID].28@PAGE -Lloh221: - add x4, x4, l_anon.[ID].28@PAGEOFF +Lloh208: + adrp x4, l_anon.[ID].23@PAGE +Lloh209: + add x4, x4, l_anon.[ID].23@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) b LBB21_1 - .loh AdrpAdd Lloh209, Lloh210 - .loh AdrpLdrGotLdr Lloh213, Lloh214, Lloh215 - .loh AdrpAdrp Lloh211, Lloh213 - .loh AdrpLdr Lloh211, Lloh212 - .loh AdrpAdd Lloh220, Lloh221 - .loh AdrpAdd Lloh218, Lloh219 - .loh AdrpAdd Lloh216, Lloh217 + .loh AdrpAdd Lloh197, Lloh198 + .loh AdrpLdrGotLdr Lloh201, Lloh202, Lloh203 + .loh AdrpAdrp Lloh199, Lloh201 + .loh AdrpLdr Lloh199, Lloh200 + .loh AdrpAdd Lloh208, Lloh209 + .loh AdrpAdd Lloh206, Lloh207 + .loh AdrpAdd Lloh204, Lloh205 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh222: +Lloh210: adrp x8, __MergedGlobals@PAGE+24 -Lloh223: +Lloh211: add x8, x8, __MergedGlobals@PAGEOFF+24 ldapr x8, [x8] cmp x8, #3 b.ne LBB22_2 -Lloh224: +Lloh212: adrp x8, __MergedGlobals@PAGE+16 -Lloh225: +Lloh213: ldr x0, [x8, __MergedGlobals@PAGEOFF+16] ret LBB22_2: @@ -1050,42 +1017,42 @@ LBB22_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh226: +Lloh214: adrp x0, __MergedGlobals@PAGE+24 -Lloh227: +Lloh215: add x0, x0, __MergedGlobals@PAGEOFF+24 -Lloh228: +Lloh216: adrp x3, l_anon.[ID].2@PAGE -Lloh229: +Lloh217: add x3, x3, l_anon.[ID].2@PAGEOFF -Lloh230: - adrp x4, l_anon.[ID].31@PAGE -Lloh231: - add x4, x4, l_anon.[ID].31@PAGEOFF +Lloh218: + adrp x4, l_anon.[ID].26@PAGE +Lloh219: + add x4, x4, l_anon.[ID].26@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh232: +Lloh220: adrp x8, __MergedGlobals@PAGE+16 -Lloh233: +Lloh221: ldr x0, [x8, __MergedGlobals@PAGEOFF+16] ret - .loh AdrpAdd Lloh222, Lloh223 - .loh AdrpLdr Lloh224, Lloh225 - .loh AdrpLdr Lloh232, Lloh233 - .loh AdrpAdd Lloh230, Lloh231 - .loh AdrpAdd Lloh228, Lloh229 - .loh AdrpAdd Lloh226, Lloh227 + .loh AdrpAdd Lloh210, Lloh211 + .loh AdrpLdr Lloh212, Lloh213 + .loh AdrpLdr Lloh220, Lloh221 + .loh AdrpAdd Lloh218, Lloh219 + .loh AdrpAdd Lloh216, Lloh217 + .loh AdrpAdd Lloh214, Lloh215 .globl _init_forgetable_ivars .p2align 2 _init_forgetable_ivars: cbz x0, LBB23_2 -Lloh234: +Lloh222: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE -Lloh235: +Lloh223: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] add x8, x0, x8 mov w9, #43 @@ -1096,15 +1063,15 @@ LBB23_2: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh236: +Lloh224: adrp x8, L_OBJC_SELECTOR_REFERENCES_af8966656b8b2b6c@PAGE -Lloh237: +Lloh225: ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_af8966656b8b2b6c@PAGEOFF] -Lloh238: +Lloh226: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE -Lloh239: +Lloh227: ldr x8, [x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGEOFF] -Lloh240: +Lloh228: ldr x8, [x8] stp x0, x8, [sp] mov x0, sp @@ -1112,24 +1079,24 @@ Lloh240: ldp x29, x30, [sp, #16] add sp, sp, #32 ret - .loh AdrpLdr Lloh234, Lloh235 - .loh AdrpLdrGotLdr Lloh238, Lloh239, Lloh240 - .loh AdrpAdrp Lloh236, Lloh238 - .loh AdrpLdr Lloh236, Lloh237 + .loh AdrpLdr Lloh222, Lloh223 + .loh AdrpLdrGotLdr Lloh226, Lloh227, Lloh228 + .loh AdrpAdrp Lloh224, Lloh226 + .loh AdrpLdr Lloh224, Lloh225 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh241: +Lloh229: adrp x8, __MergedGlobals@PAGE+40 -Lloh242: +Lloh230: add x8, x8, __MergedGlobals@PAGEOFF+40 ldapr x8, [x8] cmp x8, #3 b.ne LBB24_2 -Lloh243: +Lloh231: adrp x8, __MergedGlobals@PAGE+32 -Lloh244: +Lloh232: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret LBB24_2: @@ -1140,34 +1107,34 @@ LBB24_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh245: +Lloh233: adrp x0, __MergedGlobals@PAGE+40 -Lloh246: +Lloh234: add x0, x0, __MergedGlobals@PAGEOFF+40 -Lloh247: +Lloh235: adrp x3, l_anon.[ID].1@PAGE -Lloh248: +Lloh236: add x3, x3, l_anon.[ID].1@PAGEOFF -Lloh249: - adrp x4, l_anon.[ID].32@PAGE -Lloh250: - add x4, x4, l_anon.[ID].32@PAGEOFF +Lloh237: + adrp x4, l_anon.[ID].27@PAGE +Lloh238: + add x4, x4, l_anon.[ID].27@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh251: +Lloh239: adrp x8, __MergedGlobals@PAGE+32 -Lloh252: +Lloh240: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret - .loh AdrpAdd Lloh241, Lloh242 - .loh AdrpLdr Lloh243, Lloh244 - .loh AdrpLdr Lloh251, Lloh252 - .loh AdrpAdd Lloh249, Lloh250 - .loh AdrpAdd Lloh247, Lloh248 - .loh AdrpAdd Lloh245, Lloh246 + .loh AdrpAdd Lloh229, Lloh230 + .loh AdrpLdr Lloh231, Lloh232 + .loh AdrpLdr Lloh239, Lloh240 + .loh AdrpAdd Lloh237, Lloh238 + .loh AdrpAdd Lloh235, Lloh236 + .loh AdrpAdd Lloh233, Lloh234 .globl _init_drop_ivars .p2align 2 @@ -1184,9 +1151,9 @@ _init_drop_ivars: mov x21, x0 adrp x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE cbz x19, LBB25_2 -Lloh253: +Lloh241: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE -Lloh254: +Lloh242: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x19, x8 stp x20, x21, [x8] @@ -1200,15 +1167,15 @@ LBB25_2: mov x0, x21 bl _objc_release LBB25_3: -Lloh255: +Lloh243: adrp x8, L_OBJC_SELECTOR_REFERENCES_6edddcebbded8f32@PAGE -Lloh256: +Lloh244: ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_6edddcebbded8f32@PAGEOFF] -Lloh257: +Lloh245: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE -Lloh258: +Lloh246: ldr x8, [x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGEOFF] -Lloh259: +Lloh247: ldr x8, [x8] stp x19, x8, [sp] mov x0, sp @@ -1223,10 +1190,10 @@ LBB25_5: ldp x22, x21, [sp, #16] add sp, sp, #64 ret - .loh AdrpLdr Lloh253, Lloh254 - .loh AdrpLdrGotLdr Lloh257, Lloh258, Lloh259 - .loh AdrpAdrp Lloh255, Lloh257 - .loh AdrpLdr Lloh255, Lloh256 + .loh AdrpLdr Lloh241, Lloh242 + .loh AdrpLdrGotLdr Lloh245, Lloh246, Lloh247 + .loh AdrpAdrp Lloh243, Lloh245 + .loh AdrpLdr Lloh243, Lloh244 .section __DATA,__const .p2align 3, 0x0 @@ -1318,47 +1285,24 @@ l_anon.[ID].15: .space 39 l_anon.[ID].16: - .ascii "failed retrieving instance variable on newly declared class" - -l_anon.[ID].17: - .ascii "$WORKSPACE/objc2/src/__macro_helpers/declared_ivars.rs" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].18: - .quad l_anon.[ID].17 - .asciz "P\000\000\000\000\000\000\000\035\001\000\000\016\000\000" - - .section __TEXT,__const -l_anon.[ID].19: - .ascii "failed retrieving drop flag instance variable on newly declared class" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].20: - .quad l_anon.[ID].17 - .asciz "P\000\000\000\000\000\000\000)\001\000\000\016\000\000" - - .section __TEXT,__const -l_anon.[ID].21: .ascii "ForgetableIvars" -l_anon.[ID].22: +l_anon.[ID].17: .ascii "NoIvars" -l_anon.[ID].23: +l_anon.[ID].18: .ascii "DropIvars" -l_anon.[ID].24: +l_anon.[ID].19: .ascii "called `Option::unwrap()` on a `None` value" -l_anon.[ID].25: +l_anon.[ID].20: .ascii "$RUSTC/library/std/src/sync/once.rs" .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].26: - .quad l_anon.[ID].25 +l_anon.[ID].21: + .quad l_anon.[ID].20 .asciz "p\000\000\000\000\000\000\000\225\000\000\0002\000\000" .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2) @@ -1366,21 +1310,21 @@ l_anon.[ID].26: .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 .section __TEXT,__const -l_anon.[ID].27: +l_anon.[ID].22: .ascii "crates/$DIR/lib.rs" .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].28: - .quad l_anon.[ID].27 +l_anon.[ID].23: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000\016\000\000\000\001\000\000" .section __TEXT,__literal8,8byte_literals -l_anon.[ID].29: +l_anon.[ID].24: .ascii "NSObject" .section __TEXT,__const -l_anon.[ID].30: +l_anon.[ID].25: .ascii "NSCopying" .section __TEXT,__objc_methname,cstring_literals @@ -1491,8 +1435,8 @@ L_OBJC_IMAGE_INFO_2837f061c311eb14: .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].31: - .quad l_anon.[ID].27 +l_anon.[ID].26: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000O\000\000\000\001\000\000" .section __TEXT,__objc_methname,cstring_literals @@ -1518,8 +1462,8 @@ L_OBJC_IMAGE_INFO_af8966656b8b2b6c: .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].32: - .quad l_anon.[ID].27 +l_anon.[ID].27: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000x\000\000\000\001\000\000" .section __TEXT,__objc_methname,cstring_literals diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s b/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s index 8ba5011ac..20519bd6d 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s @@ -77,7 +77,7 @@ SYM(::call_once::<::call_once::<::call_once::<::call_once::<::call_once::<::call_once::<::class::{closure#0}>::{closure#0}, 0): @@ -290,7 +284,7 @@ SYM(::call_once::<::call_once::<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): @@ -408,7 +399,7 @@ LBB10_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].2] - lea r8, [rip + l_anon.[ID].31] + lea r8, [rip + l_anon.[ID].26] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -455,7 +446,7 @@ LBB13_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].1] - lea r8, [rip + l_anon.[ID].32] + lea r8, [rip + l_anon.[ID].27] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -492,7 +483,7 @@ LBB15_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] - lea r8, [rip + l_anon.[ID].28] + lea r8, [rip + l_anon.[ID].23] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -518,7 +509,7 @@ LBB16_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] - lea r8, [rip + l_anon.[ID].28] + lea r8, [rip + l_anon.[ID].23] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -571,7 +562,7 @@ LBB19_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] - lea r8, [rip + l_anon.[ID].28] + lea r8, [rip + l_anon.[ID].23] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -624,7 +615,7 @@ LBB21_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] - lea r8, [rip + l_anon.[ID].28] + lea r8, [rip + l_anon.[ID].23] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -647,7 +638,7 @@ LBB22_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].2] - lea r8, [rip + l_anon.[ID].31] + lea r8, [rip + l_anon.[ID].26] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -696,7 +687,7 @@ LBB24_1: mov qword ptr [rbp - 16], rax lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].1] - lea r8, [rip + l_anon.[ID].32] + lea r8, [rip + l_anon.[ID].27] lea rdx, [rbp - 16] xor esi, esi call SYM(std::sys_common::once::queue::Once::call::GENERATED_ID, 0) @@ -842,47 +833,24 @@ l_anon.[ID].15: .space 39 l_anon.[ID].16: - .ascii "failed retrieving instance variable on newly declared class" - -l_anon.[ID].17: - .ascii "$WORKSPACE/objc2/src/__macro_helpers/declared_ivars.rs" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].18: - .quad l_anon.[ID].17 - .asciz "P\000\000\000\000\000\000\000\035\001\000\000\016\000\000" - - .section __TEXT,__const -l_anon.[ID].19: - .ascii "failed retrieving drop flag instance variable on newly declared class" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].20: - .quad l_anon.[ID].17 - .asciz "P\000\000\000\000\000\000\000)\001\000\000\016\000\000" - - .section __TEXT,__const -l_anon.[ID].21: .ascii "ForgetableIvars" -l_anon.[ID].22: +l_anon.[ID].17: .ascii "NoIvars" -l_anon.[ID].23: +l_anon.[ID].18: .ascii "DropIvars" -l_anon.[ID].24: +l_anon.[ID].19: .ascii "called `Option::unwrap()` on a `None` value" -l_anon.[ID].25: +l_anon.[ID].20: .ascii "$RUSTC/library/std/src/sync/once.rs" .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].26: - .quad l_anon.[ID].25 +l_anon.[ID].21: + .quad l_anon.[ID].20 .asciz "p\000\000\000\000\000\000\000\225\000\000\0002\000\000" .zerofill __DATA,__bss,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0,8,3 @@ -891,22 +859,22 @@ l_anon.[ID].26: .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 .section __TEXT,__const -l_anon.[ID].27: +l_anon.[ID].22: .ascii "crates/$DIR/lib.rs" .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].28: - .quad l_anon.[ID].27 +l_anon.[ID].23: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000\016\000\000\000\001\000\000" .zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 .section __TEXT,__literal8,8byte_literals -L_anon.[ID].29: +L_anon.[ID].24: .ascii "NSObject" .section __TEXT,__const -l_anon.[ID].30: +l_anon.[ID].25: .ascii "NSCopying" .section __TEXT,__objc_methname,cstring_literals @@ -1018,8 +986,8 @@ L_OBJC_IMAGE_INFO_2837f061c311eb14: .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].31: - .quad l_anon.[ID].27 +l_anon.[ID].26: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000O\000\000\000\001\000\000" .zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 @@ -1047,8 +1015,8 @@ L_OBJC_IMAGE_INFO_af8966656b8b2b6c: .zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 .section __DATA,__const .p2align 3, 0x0 -l_anon.[ID].32: - .quad l_anon.[ID].27 +l_anon.[ID].27: + .quad l_anon.[ID].22 .asciz "5\000\000\000\000\000\000\000x\000\000\000\001\000\000" .zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3