[vm/ffi] Fix flaky crash of ffi/function_callbacks_test

Change-Id: If02c8dc5b6a21b05ea4d730687658cdb00128bbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104822
Auto-Submit: Samir Jindel <sjindel@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index e833159..79485c7 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -1203,6 +1203,9 @@
     __ LoadImmediate(PP, 0);  // GC safe value into PP.
   }
 
+  // Load a GC-safe value for the arguments descriptor (unused but tagged).
+  __ LoadImmediate(ARGS_DESC_REG, 0);
+
   // Load a dummy return address which suggests that we are inside of
   // InvokeDartCodeStub. This is how the stack walker detects an entry frame.
   __ LoadFromOffset(kWord, LR, THR,
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 15ae1de..610325d 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -1106,6 +1106,9 @@
     __ LoadObject(PP, compiler::NullObject());
   }
 
+  // Load a GC-safe value for the arguments descriptor (unused but tagged).
+  __ mov(ARGS_DESC_REG, ZR);
+
   // Load a dummy return address which suggests that we are inside of
   // InvokeDartCodeStub. This is how the stack walker detects an entry frame.
   __ LoadFromOffset(LR, THR,
diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc
index f71bb81..a91227a 100644
--- a/runtime/vm/compiler/backend/il_ia32.cc
+++ b/runtime/vm/compiler/backend/il_ia32.cc
@@ -1066,6 +1066,9 @@
   __ movl(Address(FPREG, kPcMarkerSlotFromFp * compiler::target::kWordSize),
           CODE_REG);
 
+  // Load a GC-safe value for the arguments descriptor (unused but tagged).
+  __ xorl(ARGS_DESC_REG, ARGS_DESC_REG);
+
   // Push a dummy return address which suggests that we are inside of
   // InvokeDartCodeStub. This is how the stack walker detects an entry frame.
   __ movl(
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index 7ffade3..ec4b97b 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -1020,7 +1020,7 @@
   // Save a space for the code object.
   __ PushImmediate(Immediate(0));
 
-  // InvokoeDartCodeStub saves the arguments descriptor here. We don't have one,
+  // InvokeDartCodeStub saves the arguments descriptor here. We don't have one,
   // but we need to follow the same frame layout for the stack walker.
   __ PushImmediate(Immediate(0));
 
@@ -1095,6 +1095,9 @@
     __ xorq(PP, PP);  // GC-safe value into PP.
   }
 
+  // Load a GC-safe value for arguments descriptor (unused but tagged).
+  __ xorq(ARGS_DESC_REG, ARGS_DESC_REG);
+
   // Push a dummy return address which suggests that we are inside of
   // InvokeDartCodeStub. This is how the stack walker detects an entry frame.
   __ movq(