From 0681b3ac9a6ab4879ca2fbfcf8aa9d00a67b8365 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 17 Jun 2024 11:03:13 +0200 Subject: Merging upstream version 115.12.0esr. Signed-off-by: Daniel Baumann --- xpcom/reflect/xptcall/md/unix/xptcinvoke_arm.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'xpcom') diff --git a/xpcom/reflect/xptcall/md/unix/xptcinvoke_arm.cpp b/xpcom/reflect/xptcall/md/unix/xptcinvoke_arm.cpp index 39a6b406f4..d66f300649 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcinvoke_arm.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcinvoke_arm.cpp @@ -164,6 +164,18 @@ NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, vtable = *reinterpret_cast(that); func = vtable[methodIndex]; +/* !!! IMPORTANT !!! + * In the case of paramCount = 0 (and also some other cases in practice but + * the compiler doesn't know about them), the stack_space is not initialized. + * Reading the stack_space is technically undefined behavior, but practically, + * the values we read from there only matter to the called function when they + * are initialized. + * The asm volatile block makes the compiler ignore that the stack_space + * may not be initialized, avoiding it optimizing away e.g. the first loop + * test in invoke_copy_to_stack. + */ + asm volatile(";"); + return func(that, stack_space[base_size * 2 - 3], stack_space[base_size * 2 - 2], stack_space[base_size * 2 - 1]); -- cgit v1.2.3